[racket] Periodic calls to collect-garbage?
This sounds like a bug. Explicit calls to `collect-garbage' shouldn't
be needed for the garage collector to do its job.
Does anyone know an easy way for me to make the problem happen, so I
can see what is going on?
At Thu, 14 Jul 2011 12:47:54 -0400, Greg Hendershott wrote:
> Once upon a time I noticed the Racket web server has a thread that
> calls collect-garbage periodically (e.g. every 5 minutes).
>
> I've discovered I need to do the same, for any program that needs to
> run for hours or days. Otherwise, the program eventually abends: Out
> of memory. Sometimes with a "Racket virtual machine error" message.
> This is my experience on both Windows 7 and on Linux, with Racket 5.0
> and 5.1.1.
>
> As a result the following has become a "magic spell" I now throw into
> such programs:
>
> ;; Make a thread to do garbage collection every 5 minutes.
> (thread
> (lambda ()
> (let loop ()
> (sleep (* 5 60))
> (collect-garbage)
> (loop))))
>
> It seems weird to have such a magic spell, and to know it only from
> nosing around the web server source.
>
> Instead, maybe the Racket runtime should do this automatically (at
> least by default)? I think that's people would expect coming from some
> other language environments with GC (at least it's what I expected).
>
> Or, at least it would be documented that this is by-design (say for
> performance reasons, or there's no reasonable default, or whatever),
> and that people should use such a magic spell for long-running
> systems?
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users