Path: utzoo!attcan!uunet!lll-winken!csd4.milw.wisc.edu!leah!rpi!batcomputer!cornell!uw-beaver!uw-june!uw-entropy!dataio!bright From: bright@Data-IO.COM (Walter Bright) Newsgroups: comp.lang.c++ Subject: Re: How much memory left in Zortech C++??? Message-ID: <1894@dataio.Data-IO.COM> Date: 1 Mar 89 19:16:28 GMT References: <1508@levels.sait.edu.au> Reply-To: bright@dataio.Data-IO.COM (Walter Bright) Organization: Data I/O Corporation; Redmond, WA Lines: 14 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.