[Mono-dev] Walking all managed objects

Joachim Ante joe at otee.dk
Tue Jul 3 12:00:37 EDT 2007


Hi Paolo,

> It sounds like you want to get weak references to the interesting
> objects (mono_gchandle_new_weakref() in the embedded API or the
> low-level GCHandle in managed code)
* We do a bunch of "temporary memory" allocations which will be  
cleaned up by the gc immediately afterwards when eg. leaving the  
function that allocated the memory.
Those allocations have to be really fast and i don't want to incur  
any extra performance penalty during normal operation.
* When loading a new level, we have a bunch of time to unload unused  
objects. We are doing a full gc_collect at this point already anyway,  
so walking it one more time isn't gonna make a big difference me thinks.

i'll gladly go with mono_gchandle_new_weakref solution you mentioned,  
if you think there is no real overhead in our use case.
Basically i would need to know that mono_gchandle_new_weakref has no  
noticable overhead when the primary use case is quickly allocating  
temporary memory (Those are always wrapper objects containing 8 bytes  
of data) and letting it be garbage collected shortly after.

> It does, but the way it does it is not exposed and it will never be
> exposed (because it's an internal detail and the user can't perform
> the same traversal safely).
Modifying the mono code for this is not a problem. Is there some  
piece of code i could look at to see how to do this?

Best regards,
Joachim Ante



More information about the Mono-devel-list mailing list