[Vm-dev] Memory leaks

KenD Ken.Dickey at Whidbey.com
Thu Dec 31 21:14:15 UTC 2015


On Thu, 31 Dec 2015 15:29:02 -0500
"Phil (list)" <pbpublist at gmail.com> wrote:

> At this stage I'm expecting to find that it's my code doing the leaking
> into the image, and not a base image or VM bug.  My original thought
> was that I had some orphaned reference loops floating around but ran
> across a post that indicated that unrooted reference loops should not
> be a problem for the VM to gc. 

Making sure such object nets are unrooted as viewed by the gc is usually the problem.

Are you making use of finalization?

Ephemerons in the newer Spur image are useful here -- but it will take some work to get an updated Cuis image in the Spur memory format.   Cuis does have a variety of weak collections which can be very helpful.

> I've done all of the obvious things I
> could think of to minimize rooted references including closing
> workspaces, browsers, inspectors, terminated Smalltalk processes etc.
>  Any ideas as to what other possible ways these objects could be
> rooted?

I tend to think of expected object lifetimes.  Having done real-time systems, one thinks of pre-allocating objects and explicitly managing object lifetimes.

If you have expected lifetimes and a "duty cycle" you should be able to nil out ivars/globals when you reach the expected "end-of-life" to orphan object nets.  The run the full collection a couple of times and check that the memory is being reclaimed.

You may be able to gc to get the memory usage, nil out a bunch of references, gc twice again, then check if the particular bunch of references made a difference.  Pick a new bunch of references and retry..

Also, you might be able to collect noted references when assigned to get candidates for testing.  

Sometimes thinking contrariwise works.  You might take a look at the objects saved in a SmartRefStream to see if things are joined in ways you don't expect.  You might write a filter which elides expected object references but notes outliers.

What tools could you build to help yourself be successful?

Also you could send me an image and we could Skype/GoogleHangout.  I sometimes find describing the problem to someone else in itself causes "aha" to happen.  

Good luck,
-KenD


More information about the Vm-dev mailing list