[racket] Memory consumption grows non-stop when re-loading a file and reusing a struct

From: Diogo F. S. Ramos (diogofsr at gmail.com)
Date: Thu Aug 8 00:13:34 EDT 2013

After defining and creating a struct with a `gen:custom-write', if one
reenters the file and asks for an element of this struct, the REPL
freezes and memory consumption grows non-stop.

Here are the steps:

$ cat "foo.rkt"
#lang racket

(struct foo
  ((define (write-proc self out mode)
     (case mode
       ((#t) (write (foo-n self) out))
       ((#f) (display (foo-n self) out))
       (else (print (foo-n self) out mode))))))
$ racket
Welcome to Racket v5.3.5.
> (enter! "foo.rkt")
> (define bar (foo 42))
> (foo-n bar)
> ; change and save foo.rkt
(enter! "foo.rkt")
  [re-loading /tmp/foo.rkt]
> (foo-n bar)
terminate break

In the steps, I killed racket.

I'm new to #:methods, so I might be doing something horribly wrong.

Posted on the users mailing list.