flush abstract method

  1. @override
Future<void> flush()
override

Flushes all caches, clearing cached class data while keeping the loader active.

This operation:

  • Clears all cached class instances
  • Removes subclass relationship caches
  • Clears interface and mixin caches
  • Resets cache statistics
  • Keeps the loader ready for new operations

When to Flush

  • Memory pressure situations
  • After dynamic class modifications
  • Periodic maintenance in long-running applications
  • Before major application phase transitions

Example

// Clear caches but keep loader active
await loader.flush();

// Loader is still usable after flush
final newClass = await loader.loadClass<String>('dart:core/string.dart.String');

Performance Impact

  • Immediate: Frees cached memory
  • Short-term: Increased loading times until cache rebuilds
  • Long-term: Improved memory efficiency

Throws IOException if cache cleanup encounters I/O errors.

Implementation

@override
Future<void> flush();