[comp.sys.mac.programmer] memory management question

jess@gn.ecn.purdue.edu (Jess M Holle) (06/26/91)

I am working on a program that will need to run in as little memory as
possible (and not take time by loading/unloading segments). I have about
4 or 5 handles that will be taking up most of the memory space, and I will
be re-sizing them a lot. I want to somehow put these handles in their own 
block of memory so that I can have keep expanding them and have them only
take memory that the other handles could use, while the rest of my program's
memory is not broken up by these handles and the amount available is not
impinged on by these handles.

My question is: is there any easy way of doing this, ie. taking advantage
of Memory Manager calls? Is a "zone" what I'm looking for? Does anyone
have any sample code, or just pseudo-code, for doing this? Any comments
on the basic memory management scheme that I'm asking about are appreciated
as well. Also, the handles should not take too much work to use, since they
are going to be used all the time in the program.

This may well be in Inside Mac, but I can't remember, don't have it, can't
afford it, and Purdue's libraries' one copy has been stolen.

Jess Holle

stevec@Apple.COM (Steve Christensen) (06/27/91)

jess@gn.ecn.purdue.edu (Jess M Holle) writes:
>I am working on a program that will need to run in as little memory as
>possible (and not take time by loading/unloading segments). I have about
>4 or 5 handles that will be taking up most of the memory space, and I will
>be re-sizing them a lot. I want to somehow put these handles in their own 
>block of memory so that I can have keep expanding them and have them only
>take memory that the other handles could use, while the rest of my program's
>memory is not broken up by these handles and the amount available is not
>impinged on by these handles.
>
>My question is: is there any easy way of doing this, ie. taking advantage
>of Memory Manager calls? Is a "zone" what I'm looking for? Does anyone
>have any sample code, or just pseudo-code, for doing this? Any comments
>on the basic memory management scheme that I'm asking about are appreciated
>as well. Also, the handles should not take too much work to use, since they
>are going to be used all the time in the program.

As long as the handles are unlocked most of the time, there's no reason why
they can't live in the app's heap along with everything else.  As the blocks
are resized, the other blocks will move around to make space for increases.
As long as you know the maximum amount of space these handles will take up,
you can adjust the app's partition size accordingly.  If you have no clue
how much this is, a separate zone wouldn't help anyway since you could run
out of space to expand a handle anyway...

steve
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Steve Christensen			Never hit a man with glasses.
  stevec@apple.com			Hit him with a baseball bat.