-
In this article, we need to know whether the program has a memory leak, and then locate which line has a memory leak, so that it can be fixed. The easiest way is, of course, with the help of professional detection tools, such as the BoundsCheck tool, which is very powerful, and I believe that people who do C++ development cannot do without it. In addition, it is not necessary to use any tools, but to implement the monitoring of memory leaks by yourself, which is divided into the following two cases:
One. Detecting memory leaks in MFC is easy if you use MFC programs. By default, there is a memory leak detection function.
We used VS2005 to generate an MFC dialog program and found that it can automatically detect memory leaks. We don't have to do anything special. If you look closely, you can see that in each CPP file, there is the following **::
#ifdef _debug
define new debug new endifdebug new This macro is defined in the file, and it helps us locate memory leaks. If you don't delete the memory allocated in the cpp file containing the above **, then when you stop the program, the VisualStudio output window will display the following message: Detected memory leaks!
dumping objects ->
d:\code\mfctest\ :normal block at 0x003af170, 4 bytes long.
data: <00 00 00 00
-
Use VLD:Visual C++ Memory Leak Detection — VLD Tool.
-
name=(char *)malloc(sizeof(char));is to allocate a memory space of the size of the char data type, i.e. name[0];
C does not do boundary detection on arrays, and can output name[100], but the content is unknown.
name=(char *)malloc(2*sizeof(char));2 char-sized memory spaces will be allocated, i.e. name[0], name[1].
It's not safe to manipulate memory space outside of array boundaries, and the data is meaningless.
Yes. (char *)malloc(sizeof(char)) is not the address of the variable name, the memory space of the variable name is the memory address allocated by malloc, which is different, i.e. name points to one address (the address allocated by malloc, and the variable name itself is another address).
Because they have scales, it improves people's productivity.
This only gives you a self-test sheet for mental health.
Mental Health Test Form. >>>More
Fried eggsIf you want to fry the eggs into a round shape. Then we need to have molds. First of all, after boiling the oil in the pan, put the mold inside, so that the fried eggs are round.
The compensation standard for illegal employment shall be carried out in accordance with the provisions of the Measures for One-time Compensation for the Personnel of Illegal Employment Units.
With Windows
With the release of 10, there are many system enthusiasts who are eager to imagine the experience of installing it. The following will teach you how to use the Universal PE Toolbox to install Windows >>>More