[Mono-devel-list] Garbage Collection and Embedding

Joe Ante joe at uti.is
Fri Jun 25 10:38:40 EDT 2004


Hi,

I just got hit by the garbage collector collecting MonoObject's that a C++
class still had a ptr to.
I am storing the ptrs in a C++ class allocated with new.
I presume that the GarbageCollector doesn¹t scan my C++ class.

Now I certainly don¹t want to allocate my C++ class using GC_ALLOC.

As far as I can see the simplest way would be to be able to mark
MonoObject's as uncollectable and when I am not interested in them anymore
mark them as collectable again.
There is a function in gc-internal.h to mark them as uncollectable, but the
implementation does nothing as far as I can see.

Am I missing something about how I should be handling ptrs to MonoObjects?

Joe Ante




More information about the Mono-devel-list mailing list