home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / mac / programm / 12898 < prev    next >
Encoding:
Internet Message Format  |  1992-07-22  |  1.3 KB

  1. Path: sparky!uunet!portal!cup.portal.com!Chewy
  2. From: Chewy@cup.portal.com (Paul Frederick Snively)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Loading Resources into MF Temp Mem.
  5. Message-ID: <62641@cup.portal.com>
  6. Date: Wed, 22 Jul 92 22:13:40 PDT
  7. Organization: The Portal System (TM)
  8. References:  <1992Jul14.200403.9031@athena.mit.edu>
  9. Lines: 19
  10.  
  11. I have an alternative, hopefully simpler, suggestion:
  12.  
  13. Use Gestalt to determine whether temporary memory is `real memory' or not.
  14. If it is, then allocate a small (say, zero byte) temporary handle, and call
  15. HandleZone on it to get the temorary zone.  Then you can GetZone the current
  16. Zone, SetZone to the temporary zone, manage memory, and when you're done,
  17. SetZone back to the old Zone.
  18.  
  19. Incidentally, when using temporary memory, it's best to _avoid_ MoveHHi,
  20. because MultiFinder/The Process Manager allocate application space _from the
  21. top down_, so MoveHHi on temporary handles will actually tend to _cause_ heap
  22. fragmentation rather than alleviate it.  Instead, you may wish to consider
  23. using ReservMem to attempt to reserve memory, and then allocate your temporary
  24. handle.  ReservMem attempts to reserve memory as _low_ in the heap as possible
  25. (it's what NewPtr calls to do its thing).
  26.  
  27. Paul Snively
  28. Dissolute Wandering Hacker
  29. chewy@apple.com
  30.