Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!sri-unix!teknowledge-vaxc!uw-beaver!tektronix!cae780!amdcad!sun!imagen!atari!apratt From: apratt@atari.UUCP Newsgroups: comp.sys.atari.st Subject: Re: how to allocate a big chunk of memory? Message-ID: <706@atari.UUCP> Date: Thu, 9-Apr-87 14:59:54 EST Article-I.D.: atari.706 Posted: Thu Apr 9 14:59:54 1987 Date-Received: Sat, 11-Apr-87 14:28:19 EST References: <4464@utah-cs.UUCP> Organization: Atari Corp., Sunnyvale CA Lines: 29 Keywords: malloc, Malloc Summary: use Malloc > [How can I get 200K dynamically, then free it?] > > -Sandra Loosemore > sandra@utah-cs.uucp, sandra@cs.utah.edu Use Malloc. If you Malloc a big block, use it, and Mfree it, all will be well. The problems with Malloc will arise when you allocate many blocks: no process should have more than 20 blocks Malloc-ed at a time. Brk, sbrk, and malloc won't help you, because they all manage the memory between your basepage and your stack pointer: this is all within one big block that was Malloc'ed when your process started up, and is unavailable to future applications anyway. Of course, you have to Mshrink before you can Malloc. But since you are planning to exec a child, I assume you have already done that. You don't always have to Mshrink before you can Malloc: The exceptions are when there is a "hole" in memory, created (for instance) when you start a shell, then start a TSR (like a ramdisk or print spooler), then leave the shell. The next process will load beyond the TSR, and the memory the shell was in will be a hole. Only explicit Malloc calls will use up this hole; programs will always load into the largest free block. /----------------------------------------------\ | Opinions expressed above do not necessarily | -- Allan Pratt, Atari Corp. | reflect those of Atari Corp. or anyone else. | ...lll-lcc!atari!apratt \----------------------------------------------/