oster@dewey.soe.berkeley.edu (David Phillip Oster) (12/31/88)
I've been bitten by the system heap versus BufPtr question. Some years ago, Apple recommended, in a tech note, that if you were going to keep something large around permananently, that you do it by manipulating BufPtr. They wanted you to do this solely because the system heap was limited in size. The BufPtr technique has the disadvantages that you can't tell what is already in high memory, and you can never give any of the memory back to the system. Think about it. This kind of memory allocation is exactly what the MemoryManager and the System Heap are for. Just after I'd spent the time to get my move-above-bufPtr-but-leave-stubs- in-the-system-heap code working, Apple changed things. They changed the system to grow the system heap as required, and provided a way for INITs to request the system heap grow before the INIT is run. (This is all documented in the StartUp Manager section of I.M. vol5, and works on any Mac with the 128k or 256k ROMs, running system software Version 5.0 or later.) In addition, I've been getting complaints on some of my commercial products that they will not run if certain hardware made by RasterOPs or Radius is installed in the system. I'll be checking today whether BufPtr is indeed the problem, but I'd expect some video boards to be sensitive to the memory map. So, the absolutely correct way to do it, is do a SysEnvirons() to see if you are running under a version of the O.S. smart enough to grow the heap. If you are, just allocate in the system heap. If you are running on an ancient machine, be prepared to move yourself above BufPtr. I hope you like testing, because when you have conditional code like this in a product, you'll need to do a lot of it. A good compromise to to forget about ancient machines, since their owners don't buy much software anyway. --- David Phillip Oster --"When we replace the mouse with a pen, Arpa: oster@dewey.soe.berkeley.edu --3 button mouse fans will need saxophone Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu --lessons." - Gasee