do I have to garbageCollect every time I create a large object?
Yoshiki.Ohshima at disney.com
Thu Aug 9 20:58:20 UTC 2001
> I have noticed something curious: after creating a very large object
> (Array new: 25000000 which ocupies 100.000.000 bytes of memory),
> everything gets very slow, and the SystemMonitor indicates constant
> incremental garbage collections.
> It is only after performing a full garbage collection (Smalltalk
> garbageCollect) that I can work again normally. My question is: do I
> have to do "Smalltalk garbageCollect" every time I create a large
> object? Or are there other ways to handle this situation?
No matter what programming language you use, if your
program is going to allocate 100s of MB of short-lived
memory chunk dynamically and repetitively, it is time to
tweak the program logic a little. You might want to recycle
previously allocated chunk or something like that. At
least, you should do some kind of explicit deallocation by
# Think about the fact that (Array new: 25000000) would take
# more than 125ms on a computer with 800MB/s memory bus
# because of the nil-out of allocation time.
And, in Squeak, calling #garbageCollect is not so bad
thing after all. You can consider the garbageCollection as
a part of the allocation of the large object. You can also
consider the nil-out variables and calling another
garbageCollection as a part of the deallocation of the
More information about the Squeak-dev