clearing GHCi (and, by extension,
hint) loaded module dependencies
i.am at toogeneric.com
Tue Oct 5 09:32:45 EDT 2010
On Oct 5, 2010, at 9:25 AM, Simon Marlow wrote:
> On 26/09/2010 18:14, Alex Suraci wrote:
>> 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
>> 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).
> How are you measuring the memory usage, btw?
I'm just looking in Activity Monitor and filtering my app's name, repeating the
tests a few times to be sure. I can try again with some other method if you'd
Also: I'll be putting together a smaller test-case soon.
More information about the Glasgow-haskell-users