Breaking on a memory allocation
I keep forgetting to write this down, so it's going on the good ole weblog for searching later.If you have your code setup to do heap allocation tracking, _CTRDBG_LEAK_CHECK_DF and you'd like to break on a specific allocation, here's what you do once you've started debugging.
Add the following to the watch window.
_crtBreakAlloc
Set the value to the allocation you'd like to break on. Now, if you're using the multi-threaded DLL runtime you'll have to provide a better context to the debugger. Like this.
{,,msvcr90d.dll}_crtBreakAlloc
So, if I'd like to see who allocated a hunk of memory, they were the 1000th caller, and they didn't free said memory, set the value to 1000, and the debugger will stop on allocation 1000.
Handy, big time handy.
Article on MSDN with more details, How to: Set Breakpoints on a Memory Allocation Number.
Labels: C++, Development, How To, Microsoft, Tricks and Tips, Visual Studio, Windows

New blogger on the street

If you're into Pharmacy Informatics, you should be following Jay, he's one of the smartest people I know, and he knows how to make your hospital pharmacy operate to its' fullest potential. I'm subscribed out of curiosity.
You can also follow him on Twitter, @jfahrni.
Labels: How To, Technology, Weblogging
