Bullet (COCOS2DX) storage leak detection

Source: Internet
Author: User

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

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.