Home Products Contracting Purchase About Contact
Home Products Contracting Purchase About Blog Contact
MemPro

C++ Memory Profiler

Supports: Windows, Unix, Linux, OSX, iOS, gcc

Note: MemPro only runs on Windows but can
connect to apps on these other platforms

Download

30 day free trial

User Guide

Please refer to the user guide for more information on MemPro.


User Guide



FAQ




Can I profile apps on Unix/gcc based systems using MemPro?

Answer: Yes. The MemPro app will only run on Windows, but you can connect over the network to an app on pretty much any platform. You can also use MemProLib in offline more if you don't have a network connection. See the User Guide for more information.



Compile errors in ws2def.h

c:\program files\microsoft sdks\windows\v7.0\include\ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition
c:\program files\microsoft sdks\windows\v7.0\include\ws2def.h(212) : error C2011: 'sockaddr' : 'struct' type redefinition

Answer:This happens because MemPro includes winsock2.h which needs to be included before windows.h. If you are including windows.h before including MemPro please add an include to winsock2

#include <winsock2.h>
#include <windows.h>

...
#include "MemPro.cpp"
After you have changed this do a full re-compile.
See here for more details on why winsock2.h needs to be included before windows.h

Alternatively, you can define WIN32_LEAN_AND_MEAN before including your windows.h. This strips out the winsock headers and avoids the problem.



When I try and view a snapshot MemPro is complaining about the DIA dll, what should I do?

Answer: Please see this page



No symbols have loaded, all I get is addresses in the callstack view, how do I fix this?

Answer: The first thing to do is to check the output window (View menu -> Show Output Window). The pdb may have failed to load because it couldn't be found or because its signature didn't match the executable. MemPro will only load pdb files if they exactly match the signature of the executable. MemPro will automatically detect where the pdb file was compiled to, and try to load it from there. If the pdb file is not there (it was compiled on another machine for example) you can add the path of the pdb file to the symbols search paths (Settings menu -> Symbols...).



My App crashes during global initialisation when linked to MemProLib

Answer: This is probably due to the initialisation of windows sockets. In MemPro.h increase the MEMPRO_INIT_DELAY. MemPro will wait this number of ms before initialising the winsock. All allocations will be stored in a temporary buffer until winsock has been initialised. Failing that you can use MemPro in offline mode by defining WRITE_DUMP. MemPro will write out to a file instead of sending data over TCP. This file can then be loaded up in MemPro.



Does MemPro work with 64Bit apps?

Answer: Yes. Both the x86 and x64 versions of MemPro can now profile 64bit apps...



Which version should I use, x86 or x64?

Answer: Both the versions can profile x86 or x64 bit apps, they are entirely equivalent. You can even load up mempro files saved from one version into the other. If you have a 64bit OS I recommend the 64bit version simply because large profiles can sometimes take up more than 3Gb of memory.



How do I get MemPro to link with an MFC app?

If you're getting link errors telling you that new and delete are already defined:

1>MCFTest_2010.obj : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in mfc100ud.lib(mfc100ud.dll)
1>MCFTest_2010.obj : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in mfc100ud.lib(mfc100ud.dll)
1>MCFTest_2010.obj : error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in msvcrtd.lib(MSVCR100D.dll)

Solution: Do a clean re-build of your entire project.

If you are still getting problems, try linking to MFC as a dll. Change 'Use of MFC' to 'Use MFC in a shared dll'.



Is there a way to use MemPro to profile my app without connecting using winsock?

Answer:Yes. Define WRITE_DUMP in MemPro.h and MemPro will write out to a file instead of sending the data over sockets. This file can then be loaded up in MemPro.



Why isn't MemPro tracking all of my allocations in my MFC app?

Solution: make sure that new isn't being re-defined to the debug version. Remove the following lines from anywhere in your code

#ifdef _DEBUG
#define new DEBUG_NEW
#endif



Compile error: 'RtlCaptureStackBackTrace': identifier not found

Answer: If you are on Win2K this function doesn't exist. Try uncommenting this line of code
//#define USE_STACKWALK64 // much slower but possibly more reliable.

Alternatively, it might be something to do with your compile settings. Please try compiling the SimpleTest sample that is installed with MemPro. If that compiles please check the compile settings for your project.



StackWalk64 compile error

Answer:Try uncommenting this line of code
//#define USE_RTLVIRTUALUNWIND

Alternatively, it might be something to do with your compile settings. Please try compiling the SimpleTest sample that is installed with MemPro. If that compiles please check the compile settings for your project.



Calling Initialise(true) to make MemPro wait for a connection isn't working

Answer: MemPro calls Initialise(WAIT_FOR_CONNECT) from TrackAlloc. This is needed because allocations can happen before main is entered (from global objects etc). It maybe that an allocation has happened before your call to Initialise(true) and Initialise(false) has already been called. to get around this problem, instead of calling Initialise(true) yourself, define WAIT_FOR_CONNECT to true in MemProLib.



Can MemPro profile applications with multiple dlls?

Answer: Yes. You will need to link to the MemProDll.dll and include MemProDll.h once in each of the dlls that you want to track. These files can be found in the MemPro code install folder. Please see the help setup in the README.txt or the help chm



MemPro is incorrectly saying that I am leaking global objects

Answer: The order of global object destruction in C++ is undefined, There are cases where MemPro can shutdown before other global objects have freed their memory. Consider explicitly cleaning up your global objects as this is generally considered good practice. If that is not an option include MemPro.h in your main application cpp file and/or the files with global objects that are not being detected. MemPro uses a trick to attempt to shutdown after everything else (see MemProGLobalScope), but it needs to be included before any other global objects are initialised. Failing that you can use MemPro in off-line mode which should catch all frees during global shutdown because it doesn't rely on sockets.



Compile error C2664: 'OutputDebugStringW' : cannot convert parameter 1 from 'const char [59]' to 'LPCWSTR'

Answer: for unicode builds, windows.h uses a different define from tchar.h. windows.h uses UNICODE and tchar.h uses _UNICODE. You must ensure that both UNICODE and _UNICODE are defined before including windows.h and tchar.h respectively. The mismatch occurs because OutputDebugString from windows.h is using the unicode version, and the string literals are wrapped in _T() from tchar.h that is not unicode.



Still have a problem? Ask here: