Oppolzer - Informatik / Stanford Pascal Compiler


Home       Lebenslauf       Schwerpunkte       Kenntnisse       Seminare       Kunden       Projekte       Produkte       Blog       Stanford Pascal       Kontakt

The Stanford Pascal Compiler / Evolution Steps

Back to Compiler main page

Dynamic Storage Management

Another task for the next days or weeks:

the compare tool uses malloc and free. I used the new procedure call to get the dynamic storage needed.

But: there is no dispose procedure to free storage in the Stanford implementation.

Because the compare tool does not free storage at the moment, it crashes after ca. 1500 lines (on both files) with the error message "Stack/Heap collision", which is the symptom for "no more storage available".

There are only two ways to get rid of unused (dynamic) storage:

The mark/release feature is only possible, because the heap is another contiguous stack that grows downwards. But it has a fixed size (allocated at program startup, the size is controlled by JCL or CMD line parameters or by default) and it cannot be extended dynamically. Stack and heap together are one fixed area and have to fit into the lower 16 MB of memory (on the mainframe).

I have some experience with the LE implementation of dynamic storage management (LE heaps), and I would like to add functions ALLOC and FREE to Stanford Pascal that support this kind of storage management. With LE storage management, additional heap segments are requested from the operating system, when needed. The FREE function uses a very sophisticated algorithm to build free element trees, so that free elements can easily be reused and storage fragmentation is minimized. I would like to code all this logic in Pascal and add it to the Stanford implementation.

I cannot remove the actual implementation involving new, mark and release completely at the moment, because it is used in the compiler, and I don't want to change that at the moment. So I would instead add ALLOC and FREE as new functions which activate the second (new) heap management.

In my installation, Stack and Heap (classical) are limited to 4 MB (on CMS). But my PASCAL CMS machine has 8 MB and could be extended further. If the "new" dynamic heap would use the remaining 4 MB, the first 4 MB would be available completely to the stack segment (which is large, IMO). This would be a large progress compared to the actual situation, and I could imagine a still larger progress, if it would be possible to move the "new" heap to the "above the line" area.

Back to Compiler main page