Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!swrinde!mips!spool.mu.edu!uunet!proto!joe From: joe@proto.com (Joe Huffman) Newsgroups: comp.os.msdos.programmer Subject: Re: Memory allocation error Message-ID: <1991May28.203501.24420@proto.com> Date: 28 May 91 20:35:01 GMT References: <1991May20.055124.24741@ariel.unm.edu> <1991May23.092728.440@sc2a.unige.ch> <1991May24.235640.17077@proto.com> <43736@netnews.upenn.edu> Organization: Prototronics @ Sandpoint, Idaho Lines: 36 theall@rm105serve.sas.upenn.edu (George A. Theall) writes: >In article <1991May24.235640.17077@proto.com> joe@proto.com (Joe Huffman) writes: >>--------- high memory -------\ >> \ >> --- Resident portion >> --magic position-- / >>----- not so high memory ----/ > How does one determine where this portion begins in high memory? Rough outline: long unsigned int mask = 1L << 20; long unsigned int M; do /* A binary search. */ { mask >>= 1; M |= mask; Allocate all of DOS memory. if(M < bytes_allocated) { Set the top 'M' bytes to 0. Free all allocated DOS memory. Exit program. if(no_crash) M ^= mask; } else M ^= mask; } while(mask != 0); Answer = 'Magic position' is M bytes from top of memory. -- joe@proto.com