Re: [Gc] Collecting large memory blocks
ivmai at mail.ru
Wed Dec 2 09:59:25 PST 2009
"Christian Gudrian" <christian at gudrian.org> wrote:
> Am 02.12.2009, 16:01 Uhr, schrieb Ivan Maidanski <ivmai at mail.ru>:
> > The test work correctly: it prints something near 1.5 MiB. Does this
> > test runs ok on your side?
> Yes. The heap sizes stays below 2 MiB.
> However, if I execute that loop in a Windows application (using Borland's
> VCL), the heap size goes up to more than 30 MiB.
> Without ALL_INTERIOR_POINTERS it stays below 10 MiB.
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.
Tip: if you have no global pointer variables, you can use the following (to prevent GC from scanning static data roots at all):
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:
GC_add_roots(&ptr1_in_data_section, (char*)&ptrN_in_data_section + sizeof(void*));
GC_add_roots(&ptr1_in_bss_section, (char*)&ptrN_in_bss_section + sizeof(void*));
> How come the collector haves differently depending on the application type
The collector knows nothing about console/Windows. Check whether the data roots addresses are the same in both cases (and also compare the address of heap (for the allocated objects)).
More information about the Gc