[comp.sys.apple] More on MemoryMgr understanding problems.

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

RE: Keith's response to my querry.......
 
>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.

I had tried the CompactMem route with the same result.  Let me show you how 
the memory was allocated in the first place...

When I need some memory for a found Identifier, I invoke the following
Function:

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

The memoryID passed to the function is the one with the AuxBits
set to $1.

When through with the cross reference listing, I then tried to freeup 
the memory as indicated earlier:

	HUnlockAll(MemId);
	DisposeAll(MemId);
{	CompactMem;   had tried this but it made no difference  }



Thanks in advance for all your help...Chris Shatara

shawn@pnet51.cts.com (Shawn Stanley) (11/05/88)

shatara@univse.dec.com (Chris Shatara, Chelmsford, Ma.) writes:
>[Keith's message + example code deleted]
>The memoryID passed to the function is the one with the AuxBits
>set to $1.

Maybe the problem lies with the original memoryID you're using?  If you don't
get your program's ID from the memory-manager and OR in the aux bits, it won't
know that the memory is auxiliary to your current program.  I'm sure you know
this, but it is a trouble spot to check.

UUCP: {rosevax, crash}!orbit!pnet51!shawn
INET: shawn@pnet51.cts.com