Pointer and memory analysis

Anthony Hannan ajh18 at cornell.edu
Fri Nov 22 03:56:23 UTC 2002


Derek Brans <brans at nerdonawire.com> wrote:
> Q1: How do you discover what is taking up that memory?

'Smalltalk spaceTally' will list bytes occuppied by class, takes a few
minutes to run.

> Q2: Once you find the culprit cancerous mesh of objects, how do you 
> discover what is holding things in memory?

The fields pane of the Inspector window has menu options called 'objects
pointing to this value' and 'chase pointers'.  'chase pointers' pops a
window that contains the chain of pointers (fields) from the Smalltalk
dictionary down to the object.

> Q3: What is the safest way to clean it up (assuming that the objects are 
> garbage and not needed).

Find out what is pointing to them and why and fix the code that is
keeping the pointers around.  Objects will be garbage collected automatically
if nothing is pointing to them.  If you don't want to bother fixing the
code right away, then you can forceably remove all pointers to an object by
changing them to point to another object, via become:.  In other words,
to get rid of object1 do 'object1 becomeForward: nil'

Cheers,
Anthony



More information about the Squeak-dev mailing list