[comp.sys.apple] Help with //gs Memory Manager commands

shatara@univse.dec.com (Chris Shatara, Chelmsford, Ma.) (11/01/88)

I am having a problem with my understanding of the UnlockAll and DisposeAll
commands of the Memory manager. 

I have a TML Pascal program where I form a binary tree of Handles (Actualy
pointers made from LOCKED handles).  This is in the body of a program I 
created for generating CrossReference listings of my programs.

Memory for each identifier is allocated using the NewHandle command 
with the Aux field of the Memory ID set to $1.  This is accomplished via

	XrefMemId := BitOr(MyMemoryId,$0100);

	( MyMemoryId is the master ID returned from the memory mgr)

Now my question......

    When I'm through printing out the cross reference listing, I want
    to deallocate and free up the space which was locked for each of the 
    identifiers in my binary tree.

    I did the following:

    	UnLockAll(XrefMemID)	{unlock all pointer with this ID}
    	DisposeAll(XrefMemID)	{free up the memory space..I think}

    Invoking FreeMem before and after the above commands shows that I
    am not gaining back memory that was allocated and in fact I'm losing
    more.

Am I interpreting these command wrongly?  I tried PurgeAll(XrefMemID) in
place of DisposeAll and had the same results?



Regards, Chris Shatara

keith@Apple.COM (Keith Rollin) (11/01/88)

In article <8810311658.AA01121@decwrl.dec.com> shatara@univse.dec.com (Chris Shatara, Chelmsford, Ma.) writes:
>
>    When I'm through printing out the cross reference listing, I want
>    to deallocate and free up the space which was locked for each of the 
>    identifiers in my binary tree.
>
>    I did the following:
>
>    	UnLockAll(XrefMemID)	{unlock all pointer with this ID}
>    	DisposeAll(XrefMemID)	{free up the memory space..I think}
>
>    Invoking FreeMem before and after the above commands shows that I
>    am not gaining back memory that was allocated and in fact I'm losing
>    more.
>
>Am I interpreting these command wrongly?  I tried PurgeAll(XrefMemID) in
>place of DisposeAll and had the same results?
>

You may also want to throw in a CompactMem() to really force the Memory 
Manager to clean up.

This one confuses me, as what you are doing should work.

The problem probably comes from the fact that the memory manager, in an effort
to do as little work as possible and hence run more quickly, may not actually
get rid of the memory you used to have allocated; it may be just marked
'available'. FreeMem() only returns the amount of memory that is actually
free for use at that instant.

Keith Rollin                               UUCP:      amdahl\
Developer Technical Support                      pyramid!sun !apple!keith
Apple Computer                                        decwrl/
                                         BITNET: keith%apple.com@relay.cs.net
"You can do what you want to me, but leave my computer alone!"