[plt-scheme] MrEd not garbage collecting invisible editors and snips

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Apr 7 00:30:12 EDT 2004

At Sat, 3 Apr 2004 15:08:25 -0500 (EST), Sarino Suon wrote:
> My MrEd application is an editor that generates a lot of temporary snips
> and their embedded editors. I often use the 'erase' method on the main
> editor to restart an editing session. 
> But the embedded snips and editors don't seem to get garbage collected. 
> My memory usage just grows and grows.
> This happens even when no copying to the clipboard is done. Also, I
> take pains to call the 'clear-undos' method on the main editor, and to
> call 'release-from-owner' on the snips.

You've already covered my usual guess (the undo stack), so I can only
suggest that you build a memory-debugging variant of MrEd to help track
down the problem.

The following show work if you're using a variant of Unix.

 1. Get the source distribution, unpack, and go into plt/src

 2. configure --enable-sgcdebug

 3. make

 4. Assuming that you already have a normal installation, setenv
    PLTHOME to point to it.

 5. cd mred

 6. ./mred -mvqM drscheme (or start your program as appropriate)

 7. Each time you clear the editor, execute
    which will write information to stderr, including counts for
    various allocated objects.

 8. If you see that the count for a particular kind of object keeps
    growing, then an extra symbol argument to `dump-memory-stats' shows
    GC traces to that kind of object. For example, if the count for
    <thread> keeps growing (probably not in your case, but just
    suppose), then

      (dump-memory-stats '<thread>)

    shows the chain of references that preserves each <thread> from GC.

These instructions are a bit sketchy, and it can go wrong in many
places. So don't hesitate to follow up if you can't get it to build or
can't get any useful information out of `dump-memory-stats'.


Posted on the users mailing list.