[comp.sys.apple] GS memory manager problems

AWCTTYPA@UIAMVS.BITNET ("David A. Lyons") (11/13/88)

>Date:         Wed, 2 Nov 88 17:25:00 GMT
>From:         "Chris Shatara, Chelmsford,
>              Ma." <univse.dec.com!shatara@DECWRL.DEC.COM>
>Subject:      More on MemoryMgr understanding problems.

>    Function NewPtr(MemID,NumBytes:integer):ptr;
>    var
>        dummy : handle
>    begin
>        dummy := NewHandle(Numbytes,MemID,FixedBank+locked,ptr(0));
>        HLock(dummy);
>        NewPtr := dummy^;
>    end;

What you're doing looks like it ought to work, including the
HUnlockAll and the  DisposeAll.

Notes:  The HLock is unnecessary since you've already specified
"locked" ($8000) in the Attributes parameter of NewHandle.  You
*should* be checking for a NIL result from NewHandle (or an error in
ToolErrorNum) in case memory was not available.  Also, you're
specifing FixedBank, which is forcing the allocated memory to be in
bank 0 (since the last parameter is NIL).  You may have meant Fixed
($4000) rather than FixedBank here--I can't see any reason for
putting your nodes all in bank 0, and I'd recommend against it since
bank 0 space is valuable for direct-page and stack space, for example.

You ought to be able to use Memory Peeker and/or Nifty List to
quickly determine exactly what's happening with your program & the
amoun tof free memory.  Nifty List is Shareware for $15 from me,
available on major online services & other places.  Memory Peeker is
built into your ROM if you have version 01; go into the Monitor
(CALL-151 from the "]" Applesoft prompt) and type a "#" and a
return. Then later when you hit Apple-Ctrl-Esc, Visit Monitor and
Memory Peeker will be available.  Memory Peeker will list all the
allocated memory blocks for you (when you hit U for Used handles),
showing their memory IDs, sizes, addresses, handles, and attributes.

Let me know if you need any more info.

--David A. Lyons              bitnet: awcttypa@uiamvs
  DAL Systems                 CompuServe:  72177,3233
  P.O. Box 287                GEnie mail:    D.LYONS2
  North Liberty, IA 52317     AppleLinkPE: Dave Lyons