Xref: utzoo comp.sys.ibm.pc:34280 comp.lang.c:21527 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!chad From: chad@csd4.csd.uwm.edu (D. Chadwick Gibbons) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: Microsoft C - Heap space question Keywords: heap microsoft-c Message-ID: <4143@csd4.csd.uwm.edu> Date: 7 Sep 89 01:31:50 GMT References: <3631@cbnewsh.ATT.COM> Sender: news@csd4.csd.uwm.edu Reply-To: chad@csd4.csd.uwm.edu (D. Chadwick Gibbons) Distribution: usa Organization: University of Wisconsin-Milwaukee Lines: 29 [yuck!] In article <3631@cbnewsh.ATT.COM> jmn@cbnewsh.ATT.COM (john.b.medamana) writes: |Is it possible to get a separate physical segment (Group?) |for heap? Normally? No, I don't believe you can. However, there is an easy way to get more heap space--which is what I assume you want. MicroSoft, and most other DOS compilers for that matter, provide a function to allocate heap space using far pointers. This way, if the heap requirements exceed 64K, it will grab another chunk of system memory. The function is declared--I believe--as "char far *farmalloc(size_t);" Note the far pointer, rather than the normal, "near", pointer. If you are using the large memory model, there should be no problem--all pointers are converted to fars and thus all pointers are thirtyt-two instead of sixteen bits wide. Be sure to read the rules on using far pointers to understand the differences and what, if any, code you might have to modify. In general, make sure you declare your pointers explicitly far. One very important note about farmalloc: usually, it will grab memory that was not original assigned to the executable when it ran. Therefore, upon normal terminal exit (via exit) this memory _will not_ be returned to the operating system. To avoid "Insufficent Memory" errors later down the road, be sure to explicitly free this allocated memory. I believe farmalloc has a corresponding free function called farfree, but check for user's guide to be exact on it's usage. Are sixteen bit segmented systems wonderful, or what?