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

Bulat Ziganshin bulat.ziganshin at gmail.com
Sat Oct 21 16:27:05 EDT 2006

Hello Andrea,

Saturday, October 21, 2006, 3:44:31 PM, you 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

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

and just after that you should call performGC. as Udo already said,
writing to file just forces all thunks to be evaluated. before
writing, you have hundreds of thousands of unevaluted functions, so
it's no wonder that so much memory used. there is a faster way to do

  return $! x==x

as Udo said, it should be better to evaluate thunks just when they are
created, by using proper 'seq' calls. another solution is to make your
fields strict by using '!':

data T = T !Int !S

but this limited to types explicitly defined by you, you can't create
lists of strict elements, for example:

data T = T [!Int]  -- impossible!

> 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.

during 2 years of developing my own program i've made memory
requirements 20 or 30 times lower. this included writing my own packed
strings lib :)))

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list