[Gc] Pointer References to GC heap
hdnews at gawab.com
Thu Sep 23 10:25:22 PDT 2004
I'm confused about the workings of GC_malloc().
Can someone explain to me how it is possible to
detect that no variables are referencing the
How does de GC collector detect that the pointers p
and q are pointing to or not pointing to allocated
memory? Does GC examine the stack?
An other example: Suppose, glib is working with the
GC_malloc and GC_free functions (which is possible).
t=(char *) gtk_entry_get_text(g); // this function actually
// returns const gchar *!
t1=(char *) GC_MALLOC(strlen(t)+3);
Note. gtk_entry_get_text() will internally allocate
a new memory block for the text and store the contents
of t1 in this memory block *and* it will (GC_free)
the previous memory block. So, t would be pointng
to freeed memory.
Will GC detect that t is still referencing the memory and
not clean it up? (my recent experiences indicate different
behaviour). Or must I leave out the GC_free function, so
that the memory of GtkEntry is explicitly left to the GC?
Thanks in advance for your answers,
More information about the Gc