Memory Leak for 2.1.4 above (easy to repro)

Look at the attached image, “Malloc 64 bytes” keeps accumulating and the heap allocated memory keeps rising.

It’s easy to repro by using the HelloCpp in 2.1.4(2.1.5) cocos2d-x sdk:

in AppController.mm, change the glview initializing code to:
EAGLView **__glView =
pixelFormat: kEAGLColorFormatRGB565
depthFormat: GL_DEPTH24_STENCIL8_OES
preserveBackbuffer: NO
sharegroup: nil
multiSampling: NO
numberOfSamples: 0];
** note we only change the pixel format and depth format, which should be allowed, right?

  1. in AppDelegate.cpp
    CCDirector::sharedDirector()>setDepthTest; // have to do this, otherwise the window shows nothing
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView;
    pDirector
    >setOpenGLView(pEGLView);

then check the instrument profile and watching memory ramping up…

Is this by design or not a big issue? Let me know what is going on. Thanks.


Screen Shot 2013-10-31 at 7.39.12 PM.png (82.7 KB)

just downloaded cocos2d-x 2.2, same issues.

yes I have seen this. I have reproduced it just be building a default project in 2.2 or 3.0 and running it on IOS 7 device (or simulator)
If you run on IOS 6.1 it does not show up for me.
Anyone have any ideas?

Jim

any follow up? cocos2d-x team? any progress???

I don’t think memory leak is a minor bug. Plz take it seriously!

I couldn’t reproduce this issue after enabling DepthTest.
I used cocos2d-x develop branch on github.

I can not reproduce it. I tested in v2.2, latest mater branch, latest develop branch.
My Xcode version 5.0.2.

And i tested on iOS 7 device and simulator.

James Chen wrote:

I couldn’t reproduce this issue after enabling DepthTest.
I used cocos2d-x develop branch on github.

not just enable depthTest, did u set GL_DEPTH24_STENCIL8_OES and kEAGLColorFormatRGB565 when setting up glView ?

I thought that PVRVFrame chips considered the GL_DEPTH24_STENCIL8_OES API an “unsupported internal format”

@Like Zhang
Yep, i have modified AppController.mm as you said.

What’s your environment?

xcode 5.0.1
cocos2d-x 2.1.5

Minggo Zhang wrote:

@Like Zhang
Yep, i have modified AppController.mm as you said.
>
What’s your environment?

Ok, i will test v2.1.5.
You said it can reproduce on v2.2, right?

@Cory Trese
You can reproduce it too?

@Minggo — no I cannot reproduce, but I do not know what I am looking for or what we are trying to do.

I changed to this:

pixelFormat: kEAGLColorFormatRGB565
depthFormat: GL_DEPTH24_STENCIL8_OES
preserveBackbuffer: NO
sharegroup: nil

and I attached my results.

it seems like it reduces performance and increases memory use.

I don’t understand what we are trying to do but I do not see any memory leaks.

Reporting back in — could not get it to memory leak on any of my devices with

pixelFormat: kEAGLColorFormatRGB565
depthFormat: GL_DEPTH24_STENCIL8_OES

but also did not find any need to add this code:

CCDirector::sharedDirector()->setDepthTest(true); // have to do this, otherwise the window shows nothing

@Cory Trese
Thanks for your feed back.
I could not found memory leak too.

I made a video for the repro:

http://www.tudou.com/programs/view/CmkFylQnV6o/

memory leak happens around 2:30

Minggo Zhang wrote:

@Cory Trese
Thanks for your feed back.
I could not found memory leak too.

The original post screenshot is cut off.

Can you sort by Live Count and see if the object that is being allocated over and over is “IOAccelResource”

Not sure if this is what u want.

attaching more details for the Malloc 64 bytes.

note the 2nd screenshot shows the malloc happens in swapbuffer
Cory Trese wrote:

The original post screenshot is cut off.
>
Can you sort by Live Count and see if the object that is being allocated over and over is “IOAccelResource”

Here is what I get running my project over an extended period.

Which does look like a leak. In my case (2.2 with default settings) Instruments and XCode 5 show constantly growing memory in three allocations — IOAccellResource, CFNumber, CFString

Not sure why — there is some stuff on Google about it impacted cocos2d-iphone users around the time of the release of iOS 7.

This post from Cocos2d-iPhone …

http://www.cocos2d-iphone.org/forums/topic/memory-keeps-counting-up-with-no-code-in-layer/

looks like the same method you are talking about ‘_dispatch_continuation_alloc_from_heap’

And this stack overflow

http://stackoverflow.com/questions/19234526/constant-app-memory-increase-ioaccelresource

shows the same diagram I am seeing.

Yet, even tho the Debug build chews up memory it does not report a Leak? Just a lot of Allocations?