[comp.lang.pascal] Exec command and dynamic allocation

kevdavis@wpi.wpi.edu (Kevin S. Davis) (07/16/90)

Well as you can probably figure out by the title, I am woundering if anyone out there has run into the same problem that I have run into.

When using the EXEC command you need to use the compiler directive $M to limit the heap size to 0 (ie. {$M 16384,0,0}).  But to have a linked list in TP5.0 you need to have a heap in order to save the list.  I have used a SwapVector command to maybe remidy the probelm but to no avail, it still doesn't work.  So can anyone out there help me?

Send your questions and anwers or just babiling information that would help, to my email address please

Thanx for everything,
Kevin davis

kevdavis@wpi.wpi.edu

phys169@canterbury.ac.nz (07/20/90)

In article <14046@wpi.wpi.edu>, kevdavis@wpi.wpi.edu (Kevin S. Davis) writes:
> When using the EXEC command you need to use the compiler directive $M to 
> limit the heap size to 0 (ie. {$M 16384,0,0}).  But to have a linked list in 
> TP5.0 you need to have a heap in order to save the list.

(a) You do need to use the $M compiler directive if you want to use Exec, but
    you *don't* need to set the heap to zero. Try {$M 16000, 1000,50000} to
    take at least 1000 bytes, and at most 50000 bytes for the heap.  If you
    know the maximum space you're likely to need, put that (round up a little
    to be on the safe side) into the third parameter.
(b) You can implement a linked list without using the heap - keep track of
    deleted elements in your own list of free elements, but you're limited
    to about 64Kbytes.
(c) If you know how much memory the program to Exec needs, and you want to 
    take all the available RAM minus that amount for your program, you have
    a problem. That's something I want to do too, and I asked about it a
    while ago without success. There probably is a messy way, involving
    taking a lot of RAM then giving some back to DOS via Dos function 49H,
    an area allocated by Turbo from the heap. Using function 4Ah is likely
    to cause problems for Turbo unless you save the Ram that is used to disk
    perhaps (you might trash some good heap data/management data otherwise),
    although if you stick with mark/release you might have less problems.
    This is definately in the area of "I really need to talk to someone who
    has done it already, because there might be some nasty problems that I
    don't know about and might not show up with a bit of testing".

Mark Aitchison, Physics, University of Canterbury, New Zealand, Up Under.