withMemoryManager<R> function
Helper function to run code with automatic memory management
Implementation
R withMemoryManager<R>(R Function(MemoryManager) action) {
final manager = MemoryManager();
try {
return action(manager);
} finally {
manager.dispose();
}
}