[Haskell-cafe] memory, garbage collection and other newbie's issues

Andrea Rossato mailing_list at istitutocolli.org
Sat Oct 21 07:44:31 EDT 2006

Hallo Bulat!

On Fri, Oct 20, 2006 at 10:21:51PM +0400, Bulat Ziganshin wrote:
> first, GC don't occurs automatically when you close file. you can help
> GHC by using performGC from System.Mem. i does it in my own prog

I did not get an appreciable improvement with performGC, as you can
see from here:

But I found a solution: just write the opml state component to a file!

At first I decided to write it and reload it:

But I get a better result by just writing it (to /dev/null or to a
real file): 

This way everything is garbage collected and the graph is what I would

Now, this is a good solution since the opml file is generally small (I
have a file with 100 subscribed feeds and it is just 46Kbyte) and it
stores information on the folder layout, so it must be saved anyway.

> second, each Char in ghc occupies 12 bytes (!), so each of your files
> occupies about 5 mb of memory. if you will count the previous problem,
> the 2 or 3 files can be hels in memory at the same time (just because
> they was not yet GCd) so memory usage may become, say, 10 mb
> multiplying this at 2.5 or even 3 factor which i described in previous
> letter means, say, 30 mb used

30 Mega used for reading a feed is a number that I seem to get. 

I also prevent the user from opening more then one feed at once. When
a new feed is opened, the old feed gets removed, the opml file is
written, the old stuff is garbage collected and the new stuff is
added. Now, the memory fingerprint of the program is given by the most
memory consuming feed. It is running at about 60-65 Mega. Not that
bad, compared to the previous situation.

Thank you very much for your suggestions.

More information about the Haskell-Cafe mailing list