Discussion on the internal leakage scheme

Source: Internet
Author: User
Tags microsoft c

In the case of out-of-memory situations, what tools should we use to perform a series of analyses, of course on wince machines, running

Time, due to limited memory 30MB, so, there is insufficient memory, taste for the Tao, now is the case, we can

By adding a macro definition, you can then capture where the memory is, be allocated, where it is not freed, to view the most memory

Assign the function and then find the related solution.


Problems encountered 1

0x75fcc42d most likely exception in RtNavi.exe: Microsoft C + + exception: Std::bad_alloc at memory location 0X0018FDB0.

Program "[6328] RtNavi.exe: Native" exited with a return value of-1 (0xFFFFFFFF).

I constantly request memory in the code, resulting in memory exhaustion, the program exits, but only the address of the program execution, and did not find

The corresponding file name and line number.



In the case of out-of-memory, it is definitely in which function, this function must be constantly repeated application, only to cause the memory is not enough, will not be a blossoming

Situation, according to the normal principle, we can also easily navigate to which of the currently executing function module will lead to insufficient memory, so, for

Out of memory situation, anthias, but we are in the process of using, and did not find any effective method, which led to even if there is a problem, we can not

Determine where the problem lies.


#include <crtdbg.h>

_CrtSetDbgFlag (_CrtSetDbgFlag (_crtdbg_report_flag) | _crtdbg_leak_check_df);

Retrieves or modifies the state of the _CRTDBGFLAG flag to control the allocation behavior of the debug heap manager (Debu G version only).

Gets or modifies the state of the _crtdgbflag to control the behavior of heap allocations in debug mode

The _CrtSetDbgFlag function allows the application to track all the behavior of the heap manager allocating memory, mainly by modifying the _CRTDBGFLAG flag bit.


What we're looking for is not a memory leak in debug mode, but a memory leak in a release mode, so we can't add any

Debug macro definition To solve the problem we have at hand, and even on the desktop version, we can not get all the source code to compile, try to

It is destined that we need to find other tools to make new attempts.



The _CrtSetDbgFlag function allows the application to control how the debug heap manager tracks memory allocations by Modi Fying the bit fields of the _CRTDBGFLAG flag. By setting the bits (turning in), the application can instruct the debug heap manager to perform special debugging Operati ONS, including checking for memory leaks when the application exits and reporting if any is found, simulating low-memory Conditions by specifying so freed memory blocks should remain in the heap ' s linked list, and verifying the integrity of The heap by inspecting each memory block at every allocation request. When _DEBUG was not defined, calls to _CrtSetDbgFlag was removed during preprocessing.


Excerpt from: http://blog.sina.com.cn/s/blog_51396f890100qjyc.html


Discussion on the internal leakage scheme

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: info-contact@alibabacloud.com 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.