[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Memory leaks - how to find them?

From: Mike Anderson
Subject: [Help-smalltalk] Memory leaks - how to find them?
Date: 27 May 2003 09:31:48 +0100

Hmm, so I'm having a look at recreating blox windows on image restart,
rather than simply abandoning them. It's actually working quite nicely,
but my test image is getting slowly bigger and bigger (up to 12MB now!).

Looking into the problem, I find that:

 BLOX.BWindow allInstances size

reports over one hundred. Needless to say, there are only a few windows
in my test setup.

Now, if you create an image with:

 PackageLoader fileInPackage: 'Browser'.
 ObjectMemory snapshot; quit!

and then repeatedly run it with:

 Transcript print: BLOX.BWindow allInstances size.
 BLOX.BLOXBrowser.BrowserMain new initialize!

and choose Smalltalk > Save Image and Smalltalk > Exit without saving,
you see the number of windows go up by one every time.

Just to complicate matters, I then tried repeatedly running the
following on a pristine image:

 ObjectMemory snapshot; quit!

and checked the size of the image afterwards. It goes up by 416 bytes
each time. 

I don't know whether this is all the same problem, anyway, I'm off to
rebuild my image from scratch to bring it back down to 2.5MB.




To try to find out what is going on, I ran the following against an
image from one iteration and against the image from the next iteration,
then diff'ed the output:

 Object allSubinstancesDo: [ :each |
        [ Transcript print: each class ] on: Error do: [ :sig |
                Transcript print: '(error)'.
        Transcript nl.

I don't know if that's valid (I appreciate that some objects will be
created before it starts running, and more will be created while it is
running). Anyway, the difference appears to be (give or take a few
objects): some Arrays, CallinProcesses, CompiledMethods, MethodContexts,
MethodInfos, WriteStreams and VFS.CStatStructs created, some
BlockClosures and Strings destroyed. All in all, there's a lot more
change than I would expect, though maybe I should have used #snapshot: 
and #quit: instead of #snapshot and #quit.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]