[comp.sys.mac.system] Setting System Heap

chuq@Apple.COM (The Bounty Hunter) (05/02/90)

steve@violet.berkeley.edu (Steve Goldfield) writes:
>1. Is this true? My heap looks like it is
>nearly 90 to 95% full. The writer says it shouldn't be more
>than 80% full.

Yes, it is. If you have an INIT or something make a request for heap memory
that can't be fulfilled, nasty things can happen. E-mail programs (that
might temporarily need a chunk of RAM for a message) are more susceptable
than others, but it's more or less general.

>2. Is there another way to change the size
>of the heap? I'm not planning to buy QuicKeys
>any time soon?

I use Widgets, which is from CE Software's Disktop. Heapfixer is another
possibility. For a standard sytem it's not a problem. If you're playing with
lots of INITs....


-- 

Chuq Von Rospach   <+>   chuq@apple.com   <+>   [This is myself speaking]

I regret to announce that--though, as I said, eleventy-one years is far too
short a time to spend among you--this is the end. I am going. Good-bye.
		-- Bilbo

asl2@tank.uchicago.edu (Aaron "Fish" Lav) (05/02/90)

In article <40672@apple.Apple.COM> chuq@Apple.COM (The Bounty Hunter) writes:
>steve@violet.berkeley.edu (Steve Goldfield) writes:
>
>>2. Is there another way to change the size
>>of the heap? I'm not planning to buy QuicKeys
>>any time soon?
>I use Widgets, which is from CE Software's Disktop. Heapfixer is another
>possibility. For a standard sytem it's not a problem. If you're playing with
>lots of INITs....

	The quickest way would be to create a file with a type of INIT
(call it Expand Sysheap) and have it be empty except for a sysz 0 resource
with the contents equal to the amount of memory you want to add.  (This
assumes that INIT 31 doesn't check for INIT resources before expanding the 
sys heap.  I haven't checked.  If it does, add an INIT 0 which is just an 
RTS (4E75).)

                               "And I guess but I just don't know"-Lou Reed
                                Aaron |><>

chewy@apple.com (Paul Snively) (05/02/90)

In article <9074@tank.uchicago.edu> asl2@tank.uchicago.edu (Aaron "Fish" 
Lav) writes:
>         The quickest way would be to create a file with a type of INIT
> (call it Expand Sysheap) and have it be empty except for a sysz 0 
resource
> with the contents equal to the amount of memory you want to add.  (This
> assumes that INIT 31 doesn't check for INIT resources before expanding 
the 
> sys heap.  I haven't checked.  If it does, add an INIT 0 which is just 
an 
> RTS (4E75).)

I wouldn't rely on this--INIT 31 is supposed to reclaim any sysz-allocated 
space that isn't actually allocated via NewHandle or NewPtr along the way. 
 I don't believe that it does so now, but it seems likely that INIT 31 
will be brought in line with its documentation someday.

__________________________________________________________________________
                                Paul Snively
                      Macintosh Developer Technical Support
                             Apple Computer, Inc.

1st Choice: Paul_Snively.DTS@gateway.qm.apple.com
2nd Choice: CHEWBACCA@applelink.apple.com
Last Choice: chewy@apple.com

Just because I work for Apple Computer, Inc. doesn't mean that I believe 
what they believe, or vice-versa.
__________________________________________________________________________

scotts@gaudi.CSUFresno.EDU (Scott Slater) (05/03/90)

In article <1990May1.231447.29824@agate.berkeley.edu> steve@violet.berkeley.edu (Steve Goldfield) writes:
>A letter in the June MacWorld suggests that some crashes
>may be caused by the system nearly filling the assigned
>system heap. The writer suggested that by increasing the
>size of his heap, he no longer experienced crashes.  He used an
>application called HeapFixer which came with QuicKeys.
>
>Two questions:
>1. Is this true? My heap looks like it is
>nearly 90 to 95% full. The writer says it shouldn't be more
>than 80% full.
>2. Is there another way to change the size
>of the heap? I'm not planning to buy QuicKeys
>any time soon?
>
>Thanks in advance,

Well to answer question #1:   Yes, it is true.  I have used HeapFixer on my
system (IIcx 6.0.4) and it works great.  The documentation says that you 
should have at least 30% free space in the system heap.

To answer question #2:  I have no of no other way to change the size of the
system heap other than using HeapFixer.  But I don't look for programs that
do this, so I'm sure there probably are.

Hope this helps!

Scott

ccc_ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) (05/03/90)

The initial heap size is governed by a parameter in the boot
blocks. (Is this what HeapFixer changes?)

Files containing INITs (i e those of type "INIT", "RDEV" or "cdev")
can have a "sysz" resource in them, which specifies the minimum
amount of contiguous free space that the code will need. The INIT 31
mechanism will expand the system heap as necessary to fill this need.

Finally, if you're running MultiFinder, the system heap isn't fixed
in size anyway.

Lawrence D'Oliveiro
Computer Services Dept                    fone: +64-71-562-889
University of Waikato                      fax: +64-71-384-066
Hamilton, New Zealand            electric mail: ldo@waikato.ac.nz
"My girlfriend's a model. At the moment she's an Airfix kit for
a Stuka dive-bomber."
		      -- Alexei Sayle

tim@hoptoad.uucp (Tim Maroney) (05/05/90)

In article <400.264065ea@waikato.ac.nz> ccc_ldo@waikato.ac.nz
(Lawrence D'Oliveiro, Waikato University) writes:
>Files containing INITs (i e those of type "INIT", "RDEV" or "cdev")
>can have a "sysz" resource in them, which specifies the minimum
>amount of contiguous free space that the code will need. The INIT 31
>mechanism will expand the system heap as necessary to fill this need.

Yes, this is correct -- and it's why the sysz suggestions for expanding
the heap won't work in the naive sense that some have suggested.  The
sysz does not add n bytes to the system heap, n bytes being the number
of bytes stored in the resource.  It make sure that there are n
contiguous bytes free in the system heap.

If you run a file which has only a sysz of 50K (and an RTS INIT to make
sure your file runs), then it will check if there are 50K free bytes.
If there are, it will allocate nothing.  But let's say your heap-hacker
INIT does cause the 50K to be allocated, because there isn't enough
free when it runs -- then the storage you've allocated may be used up
later, causing no overall expansion.  If the next INIT wants 50K, then
the next INIT's sysz will act as a no-op, because there are already 50K
bytes allocated.

So, the sysz resource solution can work, but only if you set it to the
total size you want the system heap to be, not the extra size you want
to add.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

It is not only fallacious to ignore points, or to answer them solely
with preconceived and contrived arguments:  it is also very, very
rude.  Someone who behaves in this way has only themselves to blame if
things become heated.