Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!wuarchive!uunet!mcsun!ukc!tcdcs!swift.cs.tcd.ie!dpmkelly From: dpmkelly@swift.cs.tcd.ie Newsgroups: comp.sys.mac.programmer Subject: Problem with MPW Pascal _HeapResult_ function Message-ID: <1991May6.114932.7905@swift.cs.tcd.ie> Date: 6 May 91 11:49:32 GMT Organization: Computer Science Department, Trinity College Dublin Lines: 47 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 } 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.