Re: [GD-General] memory checking
Brought to you by:
vexxed72
From: brian s. <pud...@po...> - 2004-03-05 04:17:54
|
You can probably get what you need writing your own - I imagine that's what most cross-platform and console people end up doing. It's what I did. It's easy. Assuming you have all the C allocation functions inside your own wrappers, you adjust all allocations to allocate a larger block, add guard bytes at the start and end of the block, and return a pointer to the inside of the block (you'll want to add enough bytes at the front to guarantee the same alignment that your platform's malloc delivers). You'll want to put a reference to the source file and line in that header block too, so you can see where the trashed pointer comes from. Then when the pointer's freed, you just check those guard bytes and see if they're trashed, before calling the actual free function (with the pointer adjusted downward, of course). You can also keep a list of all the pointers you've alloc'ed, and write a function that walks over all of them looking for damage. And if you have a list of all outstanding pointers, with file/line pairs, you can even start checking for leaks, if you're so inclined :) You can do fancier stuff on Win32 and Xbox, like putting allocations in separate pages and using page protections to detect overruns immediately. BoundsChecker probably does that (along with all sorts of other stuff). But it's usually enough to be able to see which pointer got nuked. If it's reproducible, you can watch a particular address in the debugger to see when it gets hit. Hope this helps, --brian Brett Bibby wrote: >I recently ran into a serious memory bug I just can't track down and it seems it's time to get some sort of memory debugging tool. Ideally it would be available for Win32, PS2 and GameCube and work with CodeWarrior, but just Windows would be acceptable. The only tools I can find so far are BoundsChecker and Purify, but neither looks like it will work with our CodeWarrior setup. I also tried just using the crtdbg funcitons, but getting the MS libs into CodeWarrior is proving problematic. > >Does anybody know of any commercial product that might be useful? Are there any standalone memory checkers out there? Anybody using BoundsChecker that can comment on whether you must have Visual Studio or not? > >Thanks, >Brett > > >------------------------------------------------------- >This SF.Net email is sponsored by: IBM Linux Tutorials >Free Linux tutorial presented by Daniel Robbins, President and CEO of >GenToo technologies. Learn everything from fundamentals to system >administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click >_______________________________________________ >Gamedevlists-general mailing list >Gam...@li... >https://lists.sourceforge.net/lists/listinfo/gamedevlists-general >Archives: >http://sourceforge.net/mailarchive/forum.php?forum_idU7 > > > |