IBM Rational purify usage record 1-solution for failure to find Memory Leak

Source: Internet
Author: User

Today, we need to use IBM Rational purify to search for memory leaking. So we started our research and the problem was immediately encountered.

I first wrote a test applet, but I found a problem with running it.


Int main ()


Char * P = new char [16];

Return 0;



Compile in vs 2003. net. If it is in debug mode, use purify to check the generated exe. No error is reported. If you compile in release mode, an error is returned. The error message is as follows:

[I] Starting purify 'd

C:/Documents and Settings/administrator. EMPIRIX-7A1AC0B/My Documents documents/Visual Studio projects/2/release/2.exe at 10:52:47

[I] starting main

[W] summary of all memory leaks... {16 bytes, 1 block}

[W] MLK: Memory Leak of 16 bytes from 1 block allocated in heap_alloc limit 2.exe]

Distribution of leaked blocks allocation heapalloc


Heap_alloc [F:/vs70builds/3077/VC/crtbld/CRT/src/malloc. C: 211]

_ Safe_se_handler_count

[C:/Documents and Settings/administrator. EMPIRIX-7A1AC0B/My Documents/Visual Studio projects/2/release/2.exe]

[I] Exiting with code 0 (0x00000000)

[I] Program terminated at 2008-05-16 10:52:49

My problem is:

1. Why is no error reported in debug mode?

2. Why can't I find my source program when an error is reported in the release mode?

The purify I use is version 7.0.

After finding a circle, I did not find a solution. Later I found the answer in IBM forum. It turned out to be a compilation and development environment problem in vs 2003. (Maybe the default Development Environment meets the requirements when other students use it. Therefore, many articles about purify do not mention changing the configuration of the compilation and development environment, but I am unlucky, it took one day to solve the problem .)


Http:// Threadid = 200784 & tstart = 15

Modify the configuration according to the recommended configuration in the online help. I suspect that the most likely error is (/fixed: No), but I am not sure.

Recommended settings for Visual Studio. net and Visual Studio 2005 related topics for managed code if you intend the data you collect to include line numbers, debug data must be available to your rational runtime analysis tool. to provide debug data, select debug configuration in the Visual Studio Configuration Manager. alternatively, compile with the/debug switch when you compile your program. consult your compiler manual for information about the location of debug data. for different ages such as C #, managed C ++, and managed Visual Basic, the debug data is present in. PDB files. for native-compiled (unmanaged) code here are the settings for Visual Studio. net and Visual Studio 2005 that work best with rational runtime analysis tools for native-compiled (unmanaged) code.

1. In the property pages for your project, C/C ++ folder, General page: Select Program database in the debug information format property drop-down list box.

2. in the C/C ++ folder, code generation page: Select default in the basic runtime checks property drop-down list box. this option setting disables the vc7 Compiler's stack frame checking.

3. In the linker folder, General page: select no in the Enable incremental linking property drop-down list box.

4. In the linker folder, command line page: In the additional options box Add:/fixed: No. This adds relocation information to your image file.

5. In the C/C ++ folder, optimization page :? For Visual Studio 2005, set whole program optimization to No.

6. In the linker folder, input page :? Clear delay loaded DLLs. If you must use this setting then you need to exclude the module that is built with this setting from instrumentation.

After changing your Visual Studio settings, you shoshould always :? Rebuild your application .? Verify that. PDB file for. EXE or. DLL is in the same directory as the corresponding. EXE or. DLL. the. PDB file contains the Microsoft format symbol information. if you move your. EXE or. DLL to a working directory, you must also move the corresponding. PDB file .? Clear your product's cache directory before running again. This forces reinstrumentation of the newly updated files. Notes :? A. DLL from the Microsoft debugger interface Access SDK is used to collect debug data from PDB files generated by Visual Studio 2005. this is installed by default with Visual Studio 2005. it uses a redistributable package, and the redistributable is installed as <install dir>/Microsoft Visual Studio 8/SDK/V2.0/bootstrapper/packages/vcredist_x86.exe. you may need to run this to install Dia if you want to run your program on a different machine than that where Visual Studio 2005 is installed. (c) Copyright IBM Corporation 1992,200 6.

After the change, the output is as follows.

[I] Starting purify 'd C:/Documents and Settings/administrator. EMPIRIX-7A1AC0B/My Documents ents/Visual Studio projects/2/debug/2.exe at 16:27:37

[I] starting main

[W] summary of all memory leaks... {10 bytes, 1 block}

[W] MLK: Memory Leak of 10 bytes from 1 block allocated in main limit 2.exe] distribution of leaked Blocks

Allocation location

Malloc [F:/vs70builds/3077/VC/crtbld/CRT/src/dbgheap. c: 138] Main [C:/Documents and Settings/administrator. empirix-7a1ac0b/My Documents/Visual Studio projects/2/2.cpp: 5]

Int main ()


=> Char * P = (char *) malloc (10 );

Return 0;


Maincrtstartup [F:/vs70builds/3077/VC/crtbld/CRT/src/crt0.c: 259]

[I] Exiting with code 0 (0x00000000)

[I] Program terminated at 2008-05-16 16:27:39

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.