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: , , , , , ,

Posted by Rob at 1:48 PM | 0 comments | Click here for a permalink to this entry.

New blogger on the street

Pharmacy LogoJerry Fahrni: "This time of year always comes with a lot of requests for medication usage data from the Pharmacy Clinical Coordinator. This year has been no exception. The most recent request was for a report identifying all medications in the pharmacy drug master that were used less than ten times in 2008. Seemed simple enough. Right." - Yes, Jerry, or Jay as the family knows him, is my brother. Jay has a PharmD from UCSF, and an insatiable need to solve Pharmacy problems using technology. He's the IT Pharmacist for Kaweah Delta District Hospital is sunny Visalia, California.

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: , ,

Posted by Rob at 10:41 AM | 0 comments | Click here for a permalink to this entry.

About

Rob Fahrni has been a Software Developer for 20 years. He's developed DOS, Windows, Linux, iPhone, and Palm based applications in C, C++, Objective-C/Cocoa, C#/ASP.Net, and, yes, even BASIC...
About >>



CrabApples.NET Home Kim Fahrni, Hacker Widow Haileigh Fahrni, My Culinary Journey Taylor Fahrni, Goin' Buggy Jerry Fahrni, Pharmacy Informatics and Technology

Apple Core Labs, LLC RxCalc - A Pharmacokinetic Calculator for iPhone

Etcetra

I work at Pelco. The opinions expressed here are my own, and neither Pelco nor any other party necessarily agrees with them.

Subscribe to ATC Send e-mail to Rob Follow me on Twitter. My Profile on LinkedIn.