[Gc] G++ exception tables and blacklisting
dej at inode.org
Thu Mar 4 16:49:19 PST 2004
I have spent the better part of a week investigating memory use in my
application. After some discussion with Hans about various contributing
factors to memory use, he has asked me to bring up the following issue.
Problem: 10-15% of the heap is blacklisted right from the start.
This was traced down to the GCC exception table. "nm" from a roughly 3 MB
executable yields in part:
08370aec d __EH_FRAME_BEGIN__
083e9538 d __FRAME_END__
084418b4 A _DYNAMIC
08441984 d __CTOR_LIST__
08441ca0 d __CTOR_END__
The space between __FRAME_END__ and _DYNAMIC is taken up by the exception
handling table, which describes the regions in the program where try-catch is
in effect, so that if an exception is thrown, the stack can be unwound
properly with all destructors being called. This region measures 362K.
The information in the exception table appears more or less random. The
problem is that a number of locations in the exception table falsely
reference locations in the collectible heap. I say "falsely" because these
references exist before the heap blocks in question are allocated. The
collector therefore blacklists the block addresses.
Although this likely does not use up any real memory or swap resources, it
does count against a user's rlimit (at least on FreeBSD). In any event, it
would be useful if the collector could determine the extent of the G++
exception table and exclude it from its root set. Unfortunately, there does
not appear to be any standard way of doing so.
More information about the Gc