[Gc] Collecting large memory blocks
christian at gudrian.org
Thu Dec 3 00:09:38 PST 2009
Am 02.12.2009, 18:59 Uhr, schrieb Ivan Maidanski <ivmai at mail.ru>:
> This is the key phrase, I think - the data roots (that are scanned by
> GC) contain values that look like pointers the allocated blocks, so the
> collector can't recycle them.
And these roots might be different depending on the application type.
> Tip: if you have no global pointer variables, you can use the following
> (to prevent GC from scanning static data roots at all):
Unfortunately I have. Some singleton classes need to store their data
> If you have a "limited set" of global pointer variables then you can try
> to inform the collector about them after GC_clear_roots like:
Sounds good. I'll have a try.
I'd rather build the collector without ALL_INTERIOR_POINTERS defined, but
thanks to multiple inheritance I need to, though that involves a lot more
work than required. For example:
Given a class C which inherits from A and B each of which have virtual
C * c = new C;
c points to the VMT of C which also happens to be the start of the memory
allocated by new. After
B * b = c;
b now points to the VMT of B, which generally differs from c. The same is
true for pointers to A.
In this example there are only three valid pointers to the memory
allocated by new. To have the collector treat these three references
correctly I need to have it treat _all_ possible references as valid (by
defining ALL_INTERIOR_POINTERS). I suppose this causes much overhead,
If it was possible to determine the pointers to the VMTs of a class and
have the collector check references only against these set of pointers,
wouldn't that improve performance?
More information about the Gc