Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!ukma!gatech!mcnc!ecsvax!utoddl From: utoddl@ecsvax.UUCP (Todd M. Lewis) Newsgroups: comp.sys.amiga.tech Subject: Re: Catching free memory violations Keywords: FreeMem monitor debug memory spam Message-ID: <7413@ecsvax.UUCP> Date: 28 Jul 89 13:23:18 GMT References: <7408@ecsvax.UUCP> <3965@cps3xx.UUCP> Organization: UNC Educational Computing Service Lines: 49 In article <3965@cps3xx.UUCP>, usenet@cps3xx.UUCP (Usenet file owner) writes: > In article <7408@ecsvax.UUCP> utoddl@ecsvax.UUCP (Todd M. Lewis) writes: > > > >I have a program which seems to use memory it doesn't own > >from time to time, and I'd like some way to catch it in the act. > >I've been thinking about a method to see if/when it messes up free > >memory, and I'd like to know why this wouldn't work: > > SOunds good. > > Easy way to Zap FreeMem is make a function called "freemem" > and then for every other module in the program, #define FreeMem freemem Perhaps I have misled you: I didn't write the program in question, nor do I have the source. I'm not even 100% absolutely sure which program it is. The failure modes make me think that some program is using memory it doesn't own. Sometimes it stomps on another program (or even itself), sometimes it stomps on free memory. I can't watch allocated RAM (heck, some of that stuff is _supposed_ to change) but free memory could be monitored. Actually, what I had in mind was to do a SetFunction() on FreeMem() so I could monitor ALL the free memory in the system, not just for programs I may be writing. I would really like to run this when I'm trying out other peoples programs (not than anyone reading this would write programs with bugs:). > > To help solve my memory trashing problems, I have sometimes replace > AllocMem & FreeMem with the above method with routines > that did the same, but tracked each Alloc and Free. The FreeMem > routine would print an error (with name of the function that called it) > if something tried to free an unalloced block or a block of the > wrong size. TO help debugging without rebooting, then you can > run thru your memory alloc list and actually free blocks that > did not otherwise get freed. That sounds like a fine solution, but to a different problem. > > REAL NAME: Joe Porkka jap@frith.cl.msu.edu (Long signature follows so posting will work. You can tell it is my signature by the way I slant my '/'s. ) _____ | Todd M. Lewis Disclaimer: If you want my employer's ||\/| utoddl@ecsvax.uncecs.edu ideas, you'll have to || || utoddl@ecsvax.bitnet _buy_ them. | || |___ (Never write a program bigger than your screen.)