The program will inevitably have a memory leak, in order to detect memory leaks, you can take a variety of measures,
Today we introduce a memory detection tool under Windows Visual Leak Detector for Visual C + +
Go to the official website to download the latest version installation.
Build a C + + console project with VS,
1. Copy the Include header file from the VLD installation directory to the C + + directory
2. Copy the Lib/win32 (if vs version 64, select Win64) to the C + + directory.
3. Put bin/win32copy to C + + Debug directory (first debug run C + +)
4. In main.cpp contains header file # include "Vld.h"
Compile run, output
Indicates no memory leaks
Modify Code
Run again
Discover a memory leak with one byte, and you will see the code location of the memory leak
In order to new COCOS2DX project memory detection convenience
1. Copy the Include header file to (vs installation directory) C:\Program files (x86) \microsoft Visual Studio 11.0\vc\include
2. Copy the Lib file to C:\Program files (x86) \microsoft Visual Studio 11.0\vc\lib
I installed the 32 copy of the Win32.
Test cocos2dx3.x New project using Cocos Engine Setup, operation
#define vld_force_enable is to turn on VLD memory detection, view vld.h header file Discovery
Only one of the two define can turn on memory detection
Shutdown program after running, found memory leak 20 bytes, OK, although there is a bit of memory leak, still can accept
(Some versions have memory leaks or not)
Now go and see if the integrated Bullet COCOS2DX program is also A memory leak of a byte, if so,
Explains that we write a few phyisics class is no memory leaks, the author after the run or a Byte, the program is still relatively stable
Bullet (COCOS2DX) storage leak detection