Over the past two days I've written a new "Starlink malloc" library
(starmem) that is a wrapper for malloc, free, realloc etc. So far so
boring. I've done this so that I can experiment with different malloc
techniques (specifically the Hans Boehm garbage collecotr). To switch
between malloc/free and the HB garbage collector you just use an
environment variable to switch between I've modified CNF and PSX to call
starmem rather than straight calls to malloc+free.
It all works fine but the big problem is that the Garbage Collector really
doesn't like it when you repeatedly malloc megabytes of memory (and it
complains).
Having this library does seem to be useful in that you can easily track
large numbers of tiny mallocs and there are many many many mallocs of <100
bytes - perfect for the Garbage Collector.
Given that we probably don't want to change the PSX interface (PSX_MALLOC
and PSX_FREE) to distinguish between large and small requests [very
difficult to do inside PSX since PSX_FREE would have to know how the
memory was allocated in the first place - this means that too new
routines would be needed in PSX for malloc and freeing large memory
blocks] my current strategy is to modify CNF so that all the cnfCr*
routines use starMalloc() and a new cnfFreeTmp routine is added to CNF
that will do the opposite of the malloc in cnfCr*. [they do not use
cnfFree at the moment]. cnfMalloc and cnfFree would have to remain with
the standard malloc. This will be my next trick (so look out for lots of
cnfFreeTmp calls replacing cnfFree)
The open question is whether we want to commit starmem to CVS and some of
my CNF and PCS patches. By default GC could be disabled (autoconfed if GC
not available).
I can commit starmem now if people want to play (to use it in A-tasks it
is necessary to patch pcs/dtask [which I've done but not committed])
--
Tim Jenness
JAC software
http://www.jach.hawaii.edu/~timj
|