[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing the Heap Size at run time

At  1:20 PM 2/8/94 -0500, Mark A. Tapia wrote:
>On 08 Feb 1994, Bill St. Clair supplied a function to grow the
>size of the mac heap, in reply to Karsten Poeck. Instead of
>Bill's function:
>(defun ensure-mac-heap-space (minimum)
>  (let ((p (#_NewPtr minimum)))
>    (unless (%null-ptr-p p)
>      (#_DisposePtr p)
>      t)))
>I used the following function, and wondered whether the two were equivalent?

They are NOT equivalent. #_NewPtr will call the GrowZone procedure if,
after compaction, there is no free block big enough to satisfy the request.
#_CompactMem does not call the GrowZone procedure. MCL's GrowZone procedure
is the code that grows the Mac Heap (and shrinks the Lisp heap).

Your check-request function WILL tell you whether attempting to allocate
a new pointer or handle of the given "minumum" size may cause a garbage
collection due to MCL's resizing of the heaps.

>(defun check-request (minimum)
>   ;; checks whether there is enough space left on the heap
>   ;; to create an object of size minimum bytes
>   ;; returns three values:
>   ;;    t when the request can be satisfied, otherwise nil
>   ;;    the actual amount available
>   ;;    the amount requested
>   (let ((actual (require-trap #_compactmem request)))
>       (values
>          (< actual request)
>          actual
>          request)))