Memory Leak for 2.1.4 above (easy to repro)

And this looks similar:

http://stackoverflow.com/questions/19111272/cocos2d-ios7-continuously-increasing-memory-usage-for-boilerplate-code?lq=1

I turned off Zombies and Debug in the environment variables on my Release target and ran for Profile.

All memory allocation growth eliminated…

We fixed some memory leak since v2.2. So it looks good with latest codes.

Hello

Cocos2d-x v 3.0 beta
new project
Windows 7
Visual Studio Express 2013

I see constant memory growth using standart Windows task manager.
Event when I commented director run with scene (and creation of Scene) memory consumption continue to grow up.
VSE does not have profiler included, so, I will try VS Ultimate, but I have no idea what will I do if I find exact issues.

Is it Cocos issue, windows or my bad understanding of the windows tasks manager?

I am trying to user crt library to define the leaks.
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

use of #define give me:
Error 2 error C2059: syntax error : ‘,’ c:2d\cocos\2d\ccdrawingprimitives.h 85 1 testgame

without it I only see
Detected memory leaks!
Dumping objects ->
{6395} normal block at 0x0370AA38, 64 bytes long.
Data: < p p p p > 20 A9 70 03 20 A9 70 03 20 A9 70 03 20 A9 70 03
{6394} normal block at 0x0370A9F0, 8 bytes long.
Data: << 3 > 3C 1F 33 00 00 00 00 00
{6393} normal block at 0x0370A9A8, 8 bytes long.
Data: <0 3 > 30 1F 33 00 00 00 00 00
{6392} normal block at 0x0370A920, 72 bytes long.
Data: < p p > 20 A9 70 03 20 A9 70 03 CD CD CD CD CD CD CD CD
{6391} normal block at 0x00331F30, 40 bytes long.
Data: < p p p > A8 A9 70 03 20 A9 70 03 00 00 00 00 F0 A9 70 03
{6390} normal block at 0x00331EB0, 64 bytes long.
Data: < 3 3 3 3 > 80 1D 33 00 80 1D 33 00 80 1D 33 00 80 1D 33 00
{6389} normal block at 0x00331E68, 8 bytes long.
Data: <$ 3 > 24 1D 33 00 00 00 00 00

and many other

Should I try another version of VS?

Some memory detection tool will treat global object(the object should be alive as long as the application) not been destroyed as memory leak.
For example, Director will not be destroyed during application lifecycle.

I am not sure if the memory leak you found is the same as i mention. If not, then it is memory leak. Could you please dig into it, and find where cause memory leak? For the pasted message, i don’t know where cause the problem.
Thanks.

I have perfomed several addtional tests and looks like memory stop to increase.
As for try to dig deeper, I will be glad, but not used C++ for ~10 years, and I have no idea how to enable extended output of ctr lib with #define _CRTDBG_MAP_ALLOC - it do not compile :frowning:
#define _CRTDBG_MAP_ALLOC
#include “stdlib.h”
#include “crtdbg.h”

Oleksiy Alyeksyeyev wrote:

I have perfomed several addtional tests and looks like memory stop to increase.
As for try to dig deeper, I will be glad, but not used C++ for ~10 years, and I have no idea how to enable extended output of ctr lib with #define _CRTDBG_MAP_ALLOC - it do not compile :frowning:
#define _CRTDBG_MAP_ALLOC
#include “stdlib.h”
#include “crtdbg.h”

You can achieve it by setting crt flags
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); // memory leak flag set

_CrtDumpMemoryLeaks(); // dumping memory leaks into console

I think you can also set something called report mode, I don’t know! I never used it though! :slight_smile:

@Delka wrote:

I am trying to user crt library to define the leaks.
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

use of #define give me:
Error 2 error C2059: syntax error : ‘,’ c:2d\cocos\2d\ccdrawingprimitives.h 85 1 testgame

without it I only see
Detected memory leaks!
Dumping objects ->
{6395} normal block at 0x0370AA38, 64 bytes long.
Data: < p p p p > 20 A9 70 03 20 A9 70 03 20 A9 70 03 20 A9 70 03
{6394} normal block at 0x0370A9F0, 8 bytes long.
Data: << 3 > 3C 1F 33 00 00 00 00 00
{6393} normal block at 0x0370A9A8, 8 bytes long.
Data: <0 3 > 30 1F 33 00 00 00 00 00
{6392} normal block at 0x0370A920, 72 bytes long.
Data: < p p > 20 A9 70 03 20 A9 70 03 CD CD CD CD CD CD CD CD
{6391} normal block at 0x00331F30, 40 bytes long.
Data: < p p p > A8 A9 70 03 20 A9 70 03 00 00 00 00 F0 A9 70 03
{6390} normal block at 0x00331EB0, 64 bytes long.
Data: < 3 3 3 3 > 80 1D 33 00 80 1D 33 00 80 1D 33 00 80 1D 33 00
{6389} normal block at 0x00331E68, 8 bytes long.
Data: <$ 3 > 24 1D 33 00 00 00 00 00

and many other

Should I try another version of VS?

Same problem here :S

Is there any solution for this?

hello,
the problem is the function CC_DEPRECATED_ATTRIBUTE void CC_DLL free(); in the CCDrawingPrimitives.h.
Just set in this header file #pragma push_macro("free") it will compile.