[plt-scheme] Snips and editors not garbage collected after copying to clipboard

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Apr 17 11:22:50 EDT 2003

At Tue, 15 Apr 2003 17:10:03 -0400, "Agnes Schemelt" wrote:
> I don't know if this issue has been brought up already, but since it shows 
> up in version 203, it seems not to have been addressed: when I copy a snip 
> to the clipboard, that copy NEVER gets garbage collected, even if I never 
> paste it.

I suspect that the problem is the Emacs-style copy ring, which keeps
the last 30 things that were copied.

Can you check whether snips start to be GC'd after 30 copies? (Maybe
you've tested this already?)

If holding on to the last 30 things causes a problem, I'm not sure how
to fix it. (But you may have found that even 60 copied snips never get
GCd, which certainly sounds like a bug.)

> This leads to another question: Why does a decorated-snip's (or any snip's) 
> "copy" method create another instance of the snip in order to write out its 
> structure to the clipboard? Why not use the current snip? Compounding this, 
> when pasting, another copy of the snip gets created again. Why so much 
> needless copying?

The answer is again the copy ring. On copy, the snip is duplicated so
that the duplicate can stay in the copy ring. On paste, the snip is
dupicated so that the duplicate in the ring is left alone.

> Perhaps it's a problem with just decorated-snip's. Yet when I create a snip 
> where its "copy" method uses its current instance to write to the clipboard, 
> I end up corrupting the editor stream when I paste.

The "copy" method uses the clipboard? Maybe the problem is an
undocumented restriction that "copy" shouldn't use the clipboard?

Matthew



Posted on the users mailing list.