Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!att!cbnewsl!rl From: rl@cbnewsl.att.com (roger.h.levy) Newsgroups: comp.lang.c Subject: balancing free() and malloc() Keywords: dynamic memory Message-ID: <1991Jun22.173609.28393@cbnewsl.att.com> Date: 22 Jun 91 17:36:09 GMT Distribution: na Organization: AT&T Bell Laboratories Lines: 15 Is there a reasonable way to determine if all malloc's in a program are balanced by free's? Since free() doesn't have a return value, it may not be clear in complex pointer manipulation situations that it's even been passed a pointer that points at dynamic memory. I was a little encouraged to see a function called coreleft() in Turbo C. I hoped that by sprinking my program with this function, I could audit the use of dynamic memory, but after some experimentation, I'm not certain what this function really reports. It may be reporting the largest available block but that prevents me from accurately seeing available memory shrink and grow. My need is to verify that an embedded systems controller won't slowly leak memory over a long haul but I can do unit testing in a UNIX or PC environment. Roger Levy rl@groucho.att.com