Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!apple!oliveb!pyramid!athertn!alex From: alex@athertn.Atherton.COM (Alex Leavens) Newsgroups: comp.sys.atari.st Subject: Re: dissassembly Summary: malloc() and Malloc() differences with MWC Message-ID: <16687@laurel.athertn.Atherton.COM> Date: 16 Jan 90 16:49:27 GMT References: <1534@cs.rit.edu> Reply-To: alex@Atherton.COM (Alex Leavens) Organization: Atherton Technology, Sunnyvale, CA Lines: 32 The difference between malloc() and Malloc() in Mark Williams C is this: Malloc() is the standard GEMDos memory allocation. malloc() is Mark William's own version of malloc, which basically tries to buffer you from some of Malloc()'s oddities. The first time you call the MWC malloc(), it does a GEMDos Malloc() of a bigger chunk than you asked for, then parcels it out to you as requested. For example, if you ask it for 10K, MWC will go out and get (say) 32K, and give you a pointer to 10K. Then if you ask for another 10K, it'll just give you a pointer to another chunk of it's remaining 22K. In doing this, you cut down on the number of calls made to Malloc(), which is good, since Malloc() will fail after some fixed (albeit large) number of calls. (The Malloc() call limit can be raised by using the FoldrXXX.prg program from Atari.) I ran into this problem myself in a program I'm writing; I was doing _lots_ of little malloc()'s (roughly 1K each), and I was supposedly "running out of memory" _much_ sooner than I should have. (I had 800K+ free, but couldn't get anymore). I put in Foldr100.prg, and the problem went away. Another alternative would be to use someone else's malloc() package; Dave Beckemeyer has one on his BBS which you can tweak to the values you want. -- |-------------------------------------------------------------------------| |--alex | alex@atherton.com | Caution! Falling Opinions, next 6 miles | | Now who are you gonna believe--me, or your own lyin' eyes? | |-------------------------------------------------------------------------|