[comp.sys.apple] IIGS Memory Manager: Help!

parker@CORONA.UOREGON.EDU (02/23/90)

A question for the GS Programming Gurus out there--but first, the Good
News and the Bad News:

The good news:  I have written a CDA which cleans up the GS's memory by
purging all purgeable memory blocks and compacting whatever's left over.
This works wonders with Appleworks GS--I no longer have to worry about
it locking up on my 1-Meg machine due to Creeping Memory Loss Disease.

The bad news:  In order to find the handles of all purgeable blocks, I
had to write a routine to scan the Memory Manager's handle list.  This
requires the use of undocumented information about the Memory Manager's
data structures (I learned about it by disassembling the Memory Peeker
CDA), so my program will probably die a horrible death if Apple ever
rewrites the Memory Manager.

And now, the question:  I would like very much to accomplish this task by
"legal" means, but a thorough search of the available documentation
reveals no such "legal" means.  Is there any Apple-approved way to purge
ALL purgeable blocks regardless of memory address or owner ID?  For that
matter, is there any Apple-approved way to do ANYTHING to a set of
handles for which the owner IDs and addresses are not known?

If this information is documented in the new Toolbox Ref. Vol. 3, I
apologize--I have no access to this information, since I'm just a poor
grad student, and I can't currently afford APDA's prices.  ($35 each for
the beta drafts, when the final editions of Vols. 1 and 2 only cost
$26.95?!?  You've got to be kidding!)

	  - Neil Parker

P.S.  If anybody out there is interested in a DA to free up all freeable
memory in the GS, let me know.  If there's enough interest, I'll post my
CDA to the net.
--
Neil Parker   parker@corona.uoregon.edu (also nparker@cie.uoregon.edu or
parker@astro.uoregon.edu)   DISCLAIMER:  Nobody anywhere believes in
these opinions.

dlyons@Apple.COM (David A. Lyons) (02/24/90)

In article <9002230935.AA06607@corona.uoregon.edu.noname> parker@CORONA.UOREGON.EDU writes:

[I wrote a CDA that purges all purgable memory blocks, and it walks
through the handle list the same way Memory Peeker does]

There's no official way to walk the handle lists, but the method Memory
Peeker uses is *unlikely*, in my opinion, to break.  (My Nifty List CDA
depends on that, too.)

>[...]  Is there any Apple-approved way to purge
>ALL purgeable blocks regardless of memory address or owner ID?

Yes:  you can do a PurgeAll(0).  It will return an error code, but it
will have done its job.  This feature appears starting in System 5.0.

>[...] I can't currently afford APDA's prices.  ($35 each for
>the beta drafts, when the final editions of Vols. 1 and 2 only cost
>$26.95?!?  You've got to be kidding!)

Please note that Volume 3 is somewhat thicker than the first two volumes.
I don't know the ins and outs of their costs (and don't want to), but I
do know they aren't making lots of dough by selling Volume 3 for $35.
-- 
David A. Lyons, Apple Computer, Inc.      |   DAL Systems
Apple II Developer Technical Support      |   P.O. Box 875
America Online: Dave Lyons                |   Cupertino, CA 95015-0875
GEnie: D.LYONS2 or DAVE.LYONS         CompuServe: 72177,3233
Internet/BITNET:  dlyons@apple.com    UUCP:  ...!ames!apple!dlyons
   
My opinions are my own, not Apple's.

gwyn@smoke.BRL.MIL (Doug Gwyn) (02/24/90)

In article <9002230935.AA06607@corona.uoregon.edu.noname> parker@CORONA.UOREGON.EDU writes:
>Is there any Apple-approved way to purge ALL purgeable blocks ...

Why don't you just try allocating a large chunk of memory and let the
memory manager take care of purging and compaction.  It does that,
you know.