Can I get a notification before fullGC?
andreas.raab at gmx.de
Thu Oct 12 02:30:33 UTC 2006
Yoshiki Ohshima wrote:
> Is there any way to get some sort of notification right *before* a
> fullGC happens so that some guys release their cache?
There is no such ability and it would make little sense to add one since
the VM doesn't know if you'll ever be able to trigger a manual GC
before it crashes. In other words: When you run out of memory you need
that memory back, and *fast*.
> Is there something I can do for this? Thank you so much!
What makes sense for a problem like you are describing is to have an
array that is cleared by the VM when running a full GC. The VM would
simply nil out everything and if there are no other (strong) references
to the objects in this array they'd get garbage collected alongside
everything else. This would give you the precise effect that the
previous (broken) weak array behavior had.
> Andreas already had a fix for it:
> http://impara.de/pipermail/tweak/2005-August/000881.html and I folded
> it to the eToys image (which should go into other images), and it
> seems to be working as expected. However, a little thing (which is
> not critical as his patch limits the upper limit of cache entries) is
> that the cache is kept even when a fullGC happens.
Personally, I find this behavior advantageous. The glyph cache can be
chosen to accommodate the working set for most use cases (I find the
current one too large by far but see below) and I wouldn't really want
to recreate the glyphs after each full GC.
BTW, if you're looking at TTFs again, the one thing you might want to
consider is to fix glyph color caching. Currently, the worst thing you
can do is to change colors. Say, when using syntax highlighting with
TTFs. Each time the color changes two bad things happen: First, we
recompute the glyph from scratch which is expensive, and second we fill
up the glyph cache with the same glyphs in different colors and
therefore throwing out previous "good" entries which means more
computation when that glyph needs to be displayed. I'll bet that fixing
glyph color caching would allow you dramatically reduce the glyph cache
size and simply ignore the whole notification on full GC issue.
More information about the Squeak-dev