From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,bda616c7992e878 X-Google-Attributes: gidf7344,public X-Google-Thread: 10f8a1,bda616c7992e878 X-Google-Attributes: gid10f8a1,public X-Google-Thread: 1164f8,bda616c7992e878 X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1993-09-09 18:17:34 PST Xref: gmd.de comp.sys.dec:10045 comp.os.vms:30342 vmsnet.alpha:831 Path: gmd.de!newsserver.jvnc.net!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!nntp-server.caltech.edu!eql.caltech.edu!rankin From: rankin@eql.caltech.edu (Pat Rankin) Newsgroups: comp.sys.dec,comp.os.vms,vmsnet.alpha Subject: Re: source to VMS C RTL malloc()? Date: 9 Sep 1993 18:06 PST Organization: California Institute of Technology Distribution: world Message-ID: <9SEP199318062471@eql.caltech.edu> References: NNTP-Posting-Host: eql7.caltech.edu News-Software: VAX/VMS VNEWS 1.41x4 In article ,\ 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