pinned byte arrays

Simon Marlow simonmarhaskell at gmail.com
Fri Oct 20 05:44:17 EDT 2006


Bulat Ziganshin wrote:
> Hello glasgow-haskell-users,
> 
> i have program that holds in memory a lot of strings (filenames) and
> use my own packed-string library to represent these string. this
> library uses newByteArray# to allocate strings. in my benchmark run
> (with 300.000 filenames in memory) program prints the following
> statistics:
> 
>  37,502,956 bytes maximum residency (16 sample(s))
> 
>        2928 collections in generation 0 (  6.90s)
>          16 collections in generation 1 ( 12.20s)
> 
>          65 Mb total memory in use
> 
> most of this memory occupied by filenames. note that 28 mb of memory
> is used just for GC procedure (i use compacting GC)

No, that 65Mb is just what the heap grew to before it was collected.  The 
compacting GC has very little overhead: just room for the mark bits (1/32 or 
1/64 of the heap size) and a few blocks for the mark stack.

You can make the size of the heap much closer to the size of the live data by 
fiddling with +RTS -F, but then you'll end up doing a lot more GC.

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list