Memory Leaking

You said “I commented the part where cocos2d was being initialised. Yet it is taking up 49Mb.” Which lines of code you commented?

In main.cpp
I commented out everything in main(). Just returned true.
But still allocations showed 49mb. From that I’m making an assumption that the 49mb that allocations shows is most likely the initial memory being assigned to the app by the os.

Can you add me up on skype ?
This is quite a major issue. If we cant get multiple sprite sheets to load then there’s no way to make a game.

Has anyone yet made anything wid cocos2dx and airplay ?

I’ve mailed you the contact info of Max Aksenov, the maintainer of airplay port.

Yeah got it .
Thanks

I emailed him but the mail bounced back.

I was able to load 4 sprite sheets of 1024x1024. Previously the issue might have been that my sprite sheet had around 800 frames.
The ones i loaded later had only around 10-20 frames.
Is there some sort of limitation on the number of frames that should be in a sprite sheet.

Hi all.

Now clearly there is a problem with releasing memory in the airplay (marmalade) module of coco2d-x.

to Zohaib Zaidi - airplay module cocos2d-x uses only standard techniques cocos2d-x for create sprite sheets. If you have allocated enough memory in the app.icf file then your sprite sheets must be loaded… But the current problem with the memory releasing probably prevent you load your sprite sheets.

We can try to find the weak points in the implementation of airplay port.
All images is loaded via the method
bool CCImage:: _initWithPngData (void * pData, int nDatalen)
perhaps this method works not quite correct? I unfortunately do not see there mistakes. If this method is working correctly then the only way to localize the problem I see in using IwMemBucket and Airplay Windows Simulator metrics.
Unfortunately I not have now access to the metrics of airplay because they are only available on Windows environment - and I do not have access now to Windows platform now - probably within a few days i will be try find solution to this problem again…

Oh, cheers! Nice to see you again, Max!

Hey thanks Max,
Ill be anxiously waiting on any findings from your side :slight_smile:
Thanks again people

to Zohaib Zaidi - really - if you load clean project of cocos2d-x then it takes into memory about 48 mb in iphone simulator… but in macOS airplay simulator it example take about 65mb… you need really check your app on real devices, because Helloworld project in iPad take only 5.0mb.
In the settings for airplay projects cocos2d-x in the file HelloWorld/Resource/app.icf by default is MemSize = [s3e] SCREENSIZE + 50,331,648 - that is only little more than you need for an empty project. So - the first recommendation to you - increase the amount of memory used in app.icf your project if test it on simulator and set empirical calculated value of memory when deploy app on current device…

Hey Max,
But shouldn’t 50Mb be more than enough just to load 4-5 sprite sheets. I loaded my code on an iphone 3gs and received the same memory assert of insufficient memory. I increased it upto 90Mb but still no use.
So you’re saying that an empty project takes upto 50Mb of memory? That is quite a lot no?

to Max - We tried to locate the reason for memory leaks in cocos2dx+marmalade and did two basic tests:
Trial1) On ccTouchesBegan event, we create a “new” CCLayer. Then on ccTouchesEnded event, we “delete” the CCLayer
Trial1 does NOT have memory leaks
2) In ccTouchesEnded event, we use replaceScene to swap a CCLayer
Trial2 DOES have memory leaks
I have created a very simple project for this problem. If you can send me an e-mail to support@pixelammo.com then I can reply and send you the project in the attachment and you can run the program.

Email sent :slight_smile:

to Zohaib Zaidi - 50 mb it’s certainly not the size of an empty project sosos2d-x … I probably did not properly expressed my thoughts … I mean that in order to test on the simulator, you can set a large enough value for that would check - is it possible to load [edited] all your spritesheets into engine cocos2d-x… because if you are not using the metric of marmalade you can not really keep track of the size of memory used - unfortunately. And just unfortunately there is a problem with the release of memory - and I can not locate it so far - marmalade without metrics is like a black box for me:)

Today, trying to solve a problem with memory, I reworked the method of loading a PNG file - bool CCImage:: _initWithPngData (void * pData, int nDatalen)
This solves some problems with PNG formats (16 bit, grayscale, etc.) but did not solve the problem with memory leaks - probably I’m looking for is not there … The next step now - try to get a metric on WIndows simulator … I can do is probably the next weekend…

I also think that we need to contact the developers Marmalade for that would they helped us solve this problem…

to Andrew Park - my email axmx.public dot gmail.com

I’m also stuck up with other projects and can’t get my hand on a windows machine…
Can you explain what you mean by “is it possible to download all your spritesheets” ? Currently I’m just adding my sprite sheets to the cocos2dx shared cache.

This is the forum link where I’m already in contact with the marmalade guys. Feel free to join in :slight_smile:
http://www.madewithmarmalade.com/devnet/forum/5084

Well, I move this project into pure ios environment (without airplay), the trail2 (*REPLACE_TEST) works well, no leaks can be found in the Instrument.

test environment: ios sdk 4.3, xcode4, click to switch between scenes more than 20 times,*REPLACE_TEST defined.

But the cocos implementation is different in both right ? like the cocos2dx airplay and cocos2d for iphone.

Yep, different.
You can look into cocos2dx/platform/, ios & airplay are two independent folder contents platform implementations.

I’m just trying to narrow down whether the issue is with the marmalade port of cocos2dx or with marmalade itself.
What you have tested is using cocos2dx for ios right ? and that cocos2dx is the same as that being run with marmalade?