[Gc] Collecting large memory blocks
hans.boehm at hp.com
Mon Dec 7 16:37:31 PST 2009
Allocating large blocks is clearly an issue. A few partial workarounds haven't been mentioned here yet:
1. Build 64-applications. That greatly reduces the probablility of misidentified pointers.
2. You can use GC_register_displacement instead of GC_all_interior_pointers. That causes the collector to recognize pointers into objects only if they refer to the right offset within the object.
3. You can allocate large objects with GC_malloc_ignore_off_page. This will result in only pointers to near the beginning of the object being treated as valid.
Actually, I was looking at this, I think we have a bit of a misfeature in this area:
We sometimes do stack marking with GC_push_all and sometimes with GC_push_all_eager, at least in the GC_all_interior_pointers case. I think the latter applies ignore_off_page to pointers on the stack, but the former doesn't, since I think it ends up using GC_base. We should be consistent. The documentation suggests that ignore_off_page is obeyed even for stack pages, though that's a bit risky because of compiler optimizations. It may require volatile pointers to objects allocated with ignore_off_page.
More information about the Gc