[racket] racket http server, major GC: -216 bytes collected

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Jan 10 08:53:36 EST 2011

At Sun, 9 Jan 2011 20:19:23 +0100, Stefan Schmiedl wrote:
> Well, that was about two hours ago. The reference GC instance is
> still idling away at 18330232 bytes, just as before, but the web server
> instance has "grown" from 47923392 (first GC of -672 bytes) to 47957512
> (first GC of -672 bytes after last "real" GC), that's about 32kB.
> Somebody's snacking on my RAM here.

There are many reasons that small amounts of memory may accumulate in
the short run --- especially caches and data structures that
periodically compact themselves.

For example, if I start Racket and just run `(collect-garbage)' in the
REPL, then after a while, I see a cycle of about 20 numbers around
-1000 and then one number around 15000. That effect seems to be from
the REPL allocating parameters that create weak boxes that are
referenced by a chain of records that are periodically compacted into a
hash table. The negative numbers don't quite balance the positive
numbers for the first many iterations of the cycle, because there's
another effect relate to rehashing (that will eventually compact a hash
table of weak boxes); I expect I'd see a larger positive number if I
had enough patience to go hundreds of times.

It's always possible that you're seeing a real leak, but I think it's
at least as likely that you're just seeing the effects of complex data
structures in the run-time system.

Meanwhile, I'm not sure why you're seeing GCs at all when the server is
idle. The GCs unexpected, right? But if you're using the LRU manager,
it seems to call `collect-garbage' along with its collection routine.

Posted on the users mailing list.