Binary IO
Jan-Willem Maessen
jmaessen at alum.mit.edu
Sat Apr 23 14:10:01 EDT 2005
On Apr 22, 2005, at 5:33 PM, Duncan Coutts wrote:
> Though arn't there some issues with the fact that regular garbage
> colection touches most of the heap (even if it doesn't modify it) and
> so
> very little of it can be paged out of physical ram.
This is a common misconception about garbage collection in general.
There are only two reasons for a garbage collector to walk through a
given piece of memory:
* The memory is live, and may contain pointers; those pointers must be
found and traced.
* A copying/compacting collector needs to move the data.
Most collectors keep a special large object area which contains big
arrays. Even if copying collection is used for other objects, these
large objects never move.
Furthermore, if an array contains no pointers (because, for example,
it's a byte array read from a file) it does not need to be scanned by
the garbage collector.
So I wouldn't worry about having your huge binary objects walked by the
garbage collector. Whatever GC may do to a heap chock-full of tiny
objects, a single large pointer-free object should be left alone.
-Jan-Willem Maessen
More information about the Libraries
mailing list