clearing GHCi (and, by extension, hint) loaded module dependencies

Alex Suraci i.am at toogeneric.com
Sun Sep 26 13:14:27 EDT 2010


On Sep 23, 2010, at 7:11 AM, Simon Marlow wrote:
> If you are making separate runGhc calls and still don't see the memory being reclaimed, then there might be a leak - but it's hard to see where, since everything is reachable from the Session only.  I suppose we have some global linker state which might be holding onto stuff, but as you say that loads are faster in subsequent runs, that implies that you're using the same Session.

Hm, I'm not doing any explicit Session handling/reusing. A new hint interpreter is run with every "load", and nothing is saved or continued between "load"s; by the time the interpreted function is executed, the interpreter has completed and its session is no longer needed. If the Session is sticking around anywhere, I'm not sure where it would be.

Slightly verbose experimentation results:

As an experiment I just tried adding hint's InterpreterT onto my language's VM stack, so that it's always running one continuous interpreter, and calling "reset" after interpreting the "load" function. An empty script bumped the usage by ~70MB, and subsequent loads of the same script had no discernible increase and completed instantly. (It seems the "reset" hint function has no effect on this.)

Loading another script after the empty one (one that actually does something - an interface for the Snap webserver) only bumped up the RAM usage modestly (30MB), implying that some of its dependencies were already loaded. Doing the reverse (snap script -> empty script) jumped the RAM usage up by ~100MB initially, and loading the empty script repeatedly had no increase and completed instantly.

Repeating these tests with separate runInterpreter calls (how it was before) has the same characteristics, except that repeated loads of already-loaded scripts bump up the RAM usage slightly (~8-10MB for empty, ~20-40MB for snap).

Hope this helps,
- Alex


More information about the Glasgow-haskell-users mailing list