ma853712@levels.sait.edu.au (Riccardo Macri) (02/17/89)
Could anyone suggest how to determine how much heap space I've got left when running a C++ program. I'm using Zortech C, with the large memory model. Thanks, Riccardo
bright@Data-IO.COM (Walter Bright) (03/02/89)
In article <1508@levels.sait.edu.au> ma853712@levels.sait.edu.au (Riccardo Macri) writes: >Could anyone suggest how to determine how much heap space I've got left when >running a C++ program. I'm using Zortech C, with the large memory model. This is a complex problem, due to 3 factors: 1. There may be DOS memory blocks unallocated to the program yet. 2. The free list maintained by malloc/free may be fragmented. 3. There may be allocated DOS memory blocking the contiguous expansion of the heap by sbrk(). So do you want the sum of all available free memory, or the largest individual piece that can be allocated (64k max with malloc), or the largest number of pieces that can be allocated of size >= n? A different strategy is required for each.