views:

141

answers:

2

Hey i need code for detecting memory leaks in win ce. I am using Visual c++. Can any one give please?

A: 

void *my_debug_malloc(size_t size)
{
  void *p = malloc(size);
  printf("malloced %d bytes at %08X\n", size, p);
  return p;
}

void my_debug_free(void *p)
{
  printf("About to free ? bytes at %08X\n", p);
  free(p);
}

#define malloc my_debug_malloc
#define free my_debug_free

// The rest of your program...

calloc, realloc is left as an exercise :)

Actually, I have debugged a lot of code using this method. But then we bought in Purify and productivity boosted...

Ernelli
+2  A: 
  • You can see Sue Loe's blog about memory tools for Windows CE: A Tour of Windows CE Memory Tools.
  • Here is the reference for Application Verifier for Windows CE 6: AppVerifier
  • Here is an article about Application Verifier 5 by Douglas Boiling. Most of it should be relevant for Windows CE 6 as well if I am not mistaken.
  • To get Application Verifier you need to download Windows CE 6 (Platform Builder 6). Free for 6 months: Download Windows CE 6
Shaihi