View Full Version : Boundschecker alternatives?
Mike Boeh
10-31-2004, 10:21 AM
Hi Guys:
I am a cheapo, and would rather find something cheap or free instead of plunking down a grand for boundschecker/Purify/Heapcheck...
Is there anything else out there that can catch memory over-runs?
Thanks!
Mike
simonh
10-31-2004, 10:26 AM
Well I've never used it myself but you might want to take a look at Fluid Studio's (www.fluidstudios.com) memory manager, which you can find at the bottom of their homepage.
Larry Hastings
10-31-2004, 10:33 AM
There's a surprisingly good one built in to the MSVC CRTL. Start with the documentation for _CrtSetDbgFlag() and work your way out to the other Debug functions.
Notes:
I use _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF); when debugging my heap.
_CrtSetBreakAlloc() is a very useful function.
Good luck!
Mark Fassett
10-31-2004, 11:00 AM
I also use the _CrtSetDbgFlag() method. Only works while debugging, but the bang for the buck is huge :)
Probably mpatrol (http://www.cbmamiga.demon.co.uk/mpatrol/mpatrol_3.html). Unfortunately, it is released under the LGPL, but it's probably ok if it's only used in debug builds.
Jim Buck
10-31-2004, 02:10 PM
Or, in a pinch, create a MyMalloc/MyFree that allocates an additional 4 bytes, stores the size request in that 4 bytes, returns a pointer that points to the byte after the 4 bytes. Then MyFree can see if anything was written after the position of the memory size request and assert accordingly.
Nutter
10-31-2004, 03:33 PM
Or, in a pinch, create a MyMalloc/MyFree that allocates an additional 4 bytes, stores the size request in that 4 bytes, returns a pointer that points to the byte after the 4 bytes. Then MyFree can see if anything was written after the position of the memory size request and assert accordingly.
A (better) extension to that is to create memory pages marked as no-access around your allocation; that way even trying to read from a location before or after your allocated memory block will cause an access violation and you to be booted into the debugger at the line that caused the error. Ah, the wonders of virtual memory. :)
Larry Hastings
10-31-2004, 10:14 PM
Or, in a pinch, create a MyMalloc/MyFree that allocates an additional 4 bytes, stores the size request in that 4 bytes, returns a pointer that points to the byte after the 4 bytes.The _CrtSetDbgFlag() stuff already does that. It's actually four bytes on either side of the allocated memory, a region they refer to as "NoMansLand".
Like I said, it's great stuff, and you've already got it... you just need to turn it on.
Powered by vBulletin™ Version 4.1.3 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.