Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!caen!ox.com!tbomb.ice.com!time From: time@tbomb.ice.com (Tim Endres) Newsgroups: comp.sys.mac.programmer Subject: Re: malloc() in Think C programming on the Mac Message-ID: <1CE00001.m1ny6l@tbomb.ice.com> Date: 28 Jan 91 12:12:23 GMT Reply-To: time@ice.com Organization: ICE Engineering, Inc. Lines: 32 X-Mailer: uAccess - Mac Release: 1.0.5+ In article <665.27A42DD4@stjhmc.fidonet.org>, Chris.Gehlker@p12.f56.n114.z1.fidonet.org (Chris Gehlker) writes: > EW> I've been using NewPtr() and NewHandle() instead of malloc(). > EW> Does any ``real'' Mac programmer know what we are really suppose > EW> to use, especially for programs that really beat on garbage collectors? > > I NEVER use malloc(). > Using NewPtr() to allocate hundreds of 8 byte objects is not very efficient on the Macintosh. This may not make any difference on your weekend programming project, but for commercial or other serious work, it is a real problem. We have a version of malloc written here at ICE specifically for the Macintosh. It is really nice and uses "pools" allowing me to separate the areas in which memory is allocated. This also solves "leak" problems, as I can allocate "leaky" objects in one specific pool, then at some predetermined time free the entire pool and not worry about freeing individual objects! We are considering posting this code to the net. Anyone interested? If so, it will take time to document the code and clean it up for release, so it won't happen soon, but it won't happen at all if there is little interest. tim. ------------------------------------------------------------- Tim Endres | time@ice.com ICE Engineering | uupsi!ice.com!time 8840 Main Street | Voice FAX Whitmore Lake MI. 48189 | (313) 449 8288 (313) 449 9208