dpmkelly@swift.cs.tcd.ie (05/06/91)
While using MacApp, I have had some problems with memory allocation. Specifically, I constructed a number of linked lists, and, not unusually, ran out of heap space. I made a rough estimate of the amount of space needed and used the _PLHeapInit_ procedure at the start of my main program file to reserve this much and a little extra. I also set the _allowNonCont_ parameter to TRUE and specified that this much memory again could be allocated if required. This all added up to about 100K; the MPW Pascal built-in heap-initialisation routine allocates just less than 5K. The problem piece of code was of this form: TYPE TElementPtr=RECORD... VAR currentElement: TElementPtr; New(currentElement); Writeln(HeapResult); Writeln(Ord4(currentElement)); PROGRAMBREAK('--- HeapResult and pointer values ---'); currentElement^.count:=c; PROGRAMBREAK('--- assignment made ---'); When run, this yielded the result (braces enclose my comments): 0 { indicates New operation was successful } $0000 { but this is not a valid pointer } --- HeapResult and pointer values --- { issued `GO' command } <machine freezes; can't even enter MacsBug> When I changed the parameters to _PLHeapInit_ so that the amount heap space allocated was drastically increased, everything was just fine. This makes me feel that _HeapResult_ is faulty. Has anybody else had this problem? I was also surprised that the initial increase was not sizable enough. By how much do MacApp's initialisation routines increase the heap size? Thanks, Dave. -- David Kelly, Department of Computer Science, Trinity College, Dublin.