Xref: utzoo comp.unix.questions:28208 comp.lang.c:35472 Path: utzoo!attcan!uunet!samsung!sdd.hp.com!caen!umich!sharkey!amara!mcdaniel From: mcdaniel@adi.com (Tim McDaniel) Newsgroups: comp.unix.questions,comp.lang.c Subject: Re: Memory allocation/deallocation for tree? Any good way? Message-ID: Date: 9 Jan 91 15:21:48 GMT References: <1991Jan7.034619.4449@portia.Stanford.EDU> Sender: news@adi.COM Followup-To: comp.unix.questions Distribution: comp Organization: Applied Dynamics International, Inc.; Ann Arbor, Michigan, USA Lines: 24 In-reply-to: fangchin@portia.Stanford.EDU's message of 7 Jan 91 03:46:19 GMT fangchin@portia.Stanford.EDU (Chin Fang) writes: From what I understand, if my malloc(3C) and free3(C) work correctly, as long as I make sure that a sequence of malloced memory blocks are freed in EXACTLY the reverse order, my program's memory consumption would stay constant no matter how many iterations it goes thru. There are no firm guarantees. A free() that did nothing would satisfy ANSI C, and there are certainly no guarantees in non-ANSI C. In most implementations, if the requests are all the same size, it doesn't matter in what order the blocks are freed. Choose any convenient order. If the size of your program is growing, it may not be your fault. Many standard libraries do their own dynamic storage allocation. There are libraries that check for memory allocation "leaks" (cases where you malloced a block and neglected to free it.) -- Tim McDaniel Applied Dynamics Int'l.; Ann Arbor, Michigan, USA Work phone: +1 313 973 1300 Home phone: +1 313 677 4386 Internet: mcdaniel@adi.com UUCP: {uunet,sharkey}!amara!mcdaniel