[Haskell] memory management

Sam Martin sam.martin at geomerics.com
Tue Aug 4 07:30:02 EDT 2009

I'm not quite sure how to describe this, but are you aware of any
research into converting heap allocations into frames on a stack?

For example, many C functions follow this kind of pattern:

void doSomeStuff(..)
	// allocate required resources
	int a,b,c;	// finite amount of temp allocations on stack
	int* buffer = malloc(..); // larger (finite) allocation on heap

	// free resources
	free(buffer); // free heap allocations
	// stack allocs popped by compiler.

They key aspect is the amount of memory required is calculatable in
advance and allocated/removed in a lump rather than a series of
requests. No pointer-tracking/garbage collection is required. 

I can picture similar situations arising in Haskell where for suitable
expressions the compiler could in theory determine that garbage
collection would be unnecessary for a lump of temporary data and simply
allocate/deallocate when starting/finishing evaluating the thunk. The
goal being to simplify garbage collection for this kind of temporary

Any thoughts?


-----Original Message-----
From: haskell-bounces at haskell.org [mailto:haskell-bounces at haskell.org]
On Behalf Of Colin Runciman
Sent: 04 August 2009 12:06
To: Nathan Ricci
Cc: Haskell at haskell.org
Subject: Re: [Haskell] memory management


>      I'm interested in research relating to memory management in 
> Haskell. I'm at the point where I don't know enough to have very 
> specific questions, but I'm especially interested in garbage
> in Haskell, and any available statistics (such as, how long does a
> typically live before its evaluated, after its evaluated?), or tools 
> that would let me get that sort of information more easily. If any one

> could be so kind as to point me to relevant research papers or other 
> documentation, it would be very much appreciated.

In the early to mid '90s we built various heap-profiling tools to 
examine the characteristics of heap data in lazy functional programs. 
You can find papers describing this work by Googling "heap profiling". 
You may be particularly interested in the investigation of "heap lag" 
and "heap drag" -- see for example the ICFP'96 paper.  Others have 
worked on similar tools since, but I'm not sure how extensive heap 
profiling facilities are in ghc, the most widely used implementation of 

Colin R

Haskell mailing list
Haskell at haskell.org

More information about the Haskell mailing list