[Gc] Problem with finalizers

Bruce Hoult bruce at hoult.org
Wed May 2 16:26:15 PDT 2007

On 5/3/07, Lothar Scholz <scholz at scriptolutions.com> wrote:
> i have written a test program that works fine. It just allocates 400
> objectes in a loop 200 of them having finalizers. This loop is
> repeated many times. No references to create objects are held after
> the loop.
> Now the strange behaviour:
> Without finalizers its fast, but with finalizers the whole app stops
> many times in the gc (as i guess) for seconds. Instead of 200 ms it
> takes about 22 sec to finish. The finalizer function is empty and
> there is no CPU load during the stops.

I've got $100 says you're swapping.

It takes memory to record the fact than an object has a finalizer.
Having a finalizer prevents objects from being collected in the first
GC after they become unreferenced, and they have to stay until the 2nd

More information about the Gc mailing list