From: rankin@eql.caltech.edu (Pat Rankin)
Subject: Re: source to VMS C RTL malloc()?
Date: 9 Sep 1993 18:06 PST [thread overview]
Message-ID: <9SEP199318062471@eql.caltech.edu> (raw)
In-Reply-To: TWILLEY.93Sep8211451@dewey.nl.nuwc.navy.mil
In article <TWILLEY.93Sep8211451@dewey.nl.nuwc.navy.mil>,\
twilley@dewey.nl.nuwc.navy.mil (Jack Twilley) writes...
> I would be interested in seeing the source code to malloc() in
> the VMS C run-time library.
You can find MALLOC.LIS in [.CRTL.LIS] on the listings kit (available
in CD format; I don't think the microfiche version is available any more).
It basically just calls LIB$GET_VM, although it does keep track of the
most recently freed block and try to reuse that when possible. If you
allocate and free a huge number of items, you might notice performance
problems after freeing lots of them. The default behavior (for LIB$FREE_VM)
is to keep the free list sorted so that adjacent blocks can be coalesced
into bigger ones, but once that list grows long, the cost of traversing it
becomes very expensive in terms of CPU time and particularly page faults.
(We have a program which could do scores or hundreds of thousands of
allocations, then eventually free all of them, but not in the same order
they were allocated; it thrashed like crazy during its own rundown until
we switched to a substitute allocator.)
V6.0 (and 1.? for Alpha) introduces new LIB$VM_MALLOC and co., which
use different strategies for allocation and release and reportedly yield
significant improvements for some usage patterns. DECC$SHR's malloc calls
those routines instead of the LIB$GET_VM family.
Pat Rankin, rankin@eql.caltech.edu
prev parent reply other threads:[~1993-09-10 2:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-09-09 1:14 source to VMS C RTL malloc()? Jack Twilley
1993-09-09 8:36 ` Andreas Fassl
1993-09-09 9:14 ` Carl J Lydick
1993-09-10 9:56 ` Don Stokes
1993-09-11 0:07 ` Carl J Lydick
1993-09-10 2:06 ` Pat Rankin [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox