Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!usc!apple!hercules!gilham From: gilham@csl.sri.com (Fred Gilham) Newsgroups: comp.sys.amiga.tech Subject: Re: Memory Protection! Message-ID: Date: 23 Aug 90 13:37:25 GMT References: <2905@mindlink.UUCP> Sender: usenet@csl.sri.com Organization: Computer Science Lab, SRI International, Menlo Park, CA. Lines: 26 In-reply-to: a218@mindlink.UUCP's message of 21 Aug 90 21:43:52 GMT Charlie Gibbs writes: ---------------------------------------- So could a Unix guru please enlighten me? Is it actually considered evil to free memory yourself, or is it one of those conventions that just grew? ---------------------------------------- I'm not claiming to be a unix guru, just the voice of experience. When I came to my current job I inherited a piece of software that generates expert systems. I started using these expert systems to process large quantities of events, and ended up dumping 32 meg cores. It turned out that there were memory leaks (failure to free() after malloc()) and also the expert systems didn't check all their calls to malloc() to make sure they succeeded. The result was that the virtual memory would be exhausted, malloc would return NULL, the program would try to use the NULL value as a real address, and the program would get aborted and write out a core file. Moral: Someone might use your program to do real work. Make sure you handle memory correctly. -- Fred Gilham gilham@csl.sri.com The emotional quality of what we moderns call our thought produces an extreme violence of conviction combined with extreme incoherence in our arguments. --Jacques Ellul