simrun
❭ modular_reduced_model_inference
❭ strategy
❭ make_weakref
make_weakref¶
- simrun.modular_reduced_model_inference.strategy.make_weakref(obj)¶
Create a weak reference of a Python object.
Objects saved on VRAM do not get cleared automatically, and memory management needs to be done manually. However, weak references get cleared by the Python garbage collector. This is a convenience method to convert Python objects to weak references, so that memory handling is more robust and practical.
Attention
A weak reference is not the same as a direct reference. Objects with references to it (i.e; referents) do not get destroyed as long as a direct reference exists. This is not the case for weak references.