clear_buffer_memory#
- class brainstate.util.clear_buffer_memory(platform=None, array=True, compilation=False)#
Clear on-device memory buffers and optionally compilation cache.
This function is useful when running models in loops to prevent memory leaks by clearing cached arrays and freeing device memory.
Warning
This operation may invalidate existing array references. Regenerate data after calling this function.
- Parameters:
- Return type:
Examples
>>> clear_buffer_memory() # Clear array buffers >>> clear_buffer_memory(compilation=True) # Also clear compilation cache