[Vm-dev] Memory leaks

KenD Ken.Dickey at Whidbey.com
Thu Dec 31 16:14:10 UTC 2015


On Thu, 31 Dec 2015 03:36:46 -0500
"Phil (list)" <pbpublist at gmail.com> wrote:

> I was curious if the VM has any facilities to assist in tracking down
> memory leaks? (not in the VM itself, but rather in the image it is
> running)  The scenario that comes to mind are object reference loops
> though there are likely others to consider as well.  Any pointers are
> appreciated.

Hi Phil,

It depends on what, specifically, you are doing.

There are tools in Caregory Tools-ReferenceFinder which I suspect would be of help.

From http://blogten.blogspot.com/

"New Reference Finder / Weight Tracer

During ESUG's Show Us Your Projects, I gave a demo of a really fast reference finder I had written in Cuis a number of years ago.  During ESUG, Jan Vrany and I wrote an enhancement to the reference finder: a so-called weight tracer.  What this tracer does is tell you which objects only "hang" from a given object.  That is, if the given object goes away, the weight tracer shows what other objects would be collected as well.

Initially, the weight tracer required about two minutes per scan.  I managed to cut that in half at ESUG with some less than ideal hackery.  But today I really understood what was going on.  After deleting the unnecessary hackery, and with just a few tiny changes, the weight tracer runs just as quickly as the reference finder: a couple tenths of a second."

====  ====

In the limit, any deep memory bug is probably investigated in a VM simulator.  This type of bug in a released image is rare.  Typical images do not load the object-memory/vm simulator, but you can build a VMMaker image which has the code.

Note that this is for people with deep knowledge.  You have to understand how objects are represented in memory, Cog (JIT) vs non-Cog, Spur vs non-Spur,  StackInterpreter vs optimized, ...

Two article blogs discuss the deeper currents within the VM:
 http://www.mirandabanda.org/cogblog/
 https://clementbera.wordpress.com/author/clementbera/

Note that because of the Squeak/Pharo/Cuis community, you can safely ignore the VM and play happily in Smalltalk, so don't feel you have to dive into this level of operations unless you have the calling for it (i.e. you are walking alone and something reaches out from the earth, grabs your ankle, and down you go.  Hey, it happens!).

Cheers,
-KenD


More information about the Vm-dev mailing list