Debugging: ACE, Windows, and Memory Leak Detection

Code Monkey No Comments

ACE LogoThe Windows development environment provided by VisualStudio has some neat tools for detecting memory leaks in code. You simply #define _CRTDBG_MAP_ALLOC before including your headers, and #include <crtdbg.h> as the last header:

#define _CRTDBG_MAP_ALLOC

// Include header files here

#include <crtdbg.h>

Then, you call _CrtDumpMemoryLeaks() before your application exits. If your program exits at many points, you can alternatively call _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ) at the beginning of you application, which will cause the leaks to also be printed when it exits. The results are printed to the Debug Window and look like the following:

Detected memory leaks!
Dumping objects ->
C:\PROGRAM FILES\VISUAL STUDIO\MyProjects\leaktest\leaktest.cpp(20) : {18}
normal block at 0×00780E80, 64 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.

Cool, Huh?! However, some libraries don’t play nice with this, as I explain below.

Read the rest…

C++ Portable Runtime Evaluation

Code Monkey No Comments

I recently (June 2007) did an evaluation of C++ portable runtimes for my employer (a large video security company) for use in our system level code. We were looking for a set of libraries that would abstract the operating system (threads, IPC, File I/O, etc) and allow our code to be portable across many architectures and environments. I’ve decided to publish the results of my evaluation here for anyone interested in portable runtimes.
Spoiler: We chose to go with the ACE version 5.4.1.
I initially considered the following runtimes for evaluation:

After considering the criteria we were using for evaluation (see below), I narrowed the field down to 3 candidates:

  • ACE
  • POCO
  • PTypes

I’ve included the selection criteria and evaluation results below. Happy reading.

UPDATE 11/14/2008: Read my post about problems with ACE and debugging memory leaks in Windows.

Read the rest…