Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4084390
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:26:02+00:00 2026-05-20T18:26:02+00:00

I am developing a cocos2d based app and I am now testing it against

  • 0

I am developing a cocos2d based app and I am now testing it against the Allocations Tool to check whether some leakage is present. I have noticed there are instants at which a malloc of 16 MB occurs and I can actually not say why. I guess it is something related to the cocos framework but I am not sure of it.

Have you ever experienced the same behaviour? Sometimes the app crashes because of this during the tests.

Thank you in advance

Andrea

Some Futher Details

It seems the problem is related to the way cocos caches sprites. I am using zwoptex texture atlas. Here is the call stack

+[CCSpriteSheet spriteSheetWithFile:capacity:] CCSpriteSheet.m:69 
-[CCSpriteSheet initWithFile:capacity:] CCSpriteSheet.m:104 
-[CCTextureCache addImage:] CCTextureCache.m:243 
-[CCTexture2D(Image) initWithImage:] CCTexture2D.m:207 
-[CCTexture2D(Image) initPremultipliedATextureWithImage:pixelsWide:pixelsHigh:]    

In that point of the execution I am actually loading the largest sprite I have. It is about 900KB. While the others are very little . Am I using cocos in the wrong way?.
For example are there parameters aimed at reducing such peaks.
However I would expect that once cached the image would not be loaded any time I need it. Instead I experience new spikes any time I do not use such sprite for some time.
I then guessed the cache would not be cleared if I reteined the image but despite of the fact I retain it the malloc still occurs.

I would also like to know why the application RAM footprint changes from 3MB to 80MB when running on the simulator instead of the device

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:26:03+00:00Added an answer on May 20, 2026 at 6:26 pm

    Ok I guess I can answer my question

    I found this method in the app delegate automatically generated when a new cocos2d project is created

    -(void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
        [[CCDirector sharedDirector] purgeCachedData];
    }
    

    It seems therefore that as soon as the app receives a memory warning the cache is purged. So When I instantiate my 900KB sprite the first time 16MB are allocated (still very strange indeed) and when some times during the execution a memory warning is thrown the cache is purged and it has to load it again. Does it make any sense to you?

    Anyway I have commented it and the game seems faster, obviously I have to check very well there are no memory leakages but I am actually pretty sure of it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an iphone game using cocos2d and have it set to to
I am developing an iPhone app using cocos2d and box2d.In this app i require
Developing a .NET WinForms application: how can I check if the window is in
Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
When developing whether its Web or Desktop at which point should a developer switch
When developing a new web based application which version of html should you aim
I am developing iPhone 2d game by using cocos2d. I need a Picker. Is
I am developing a 2d game for iPhone by using cocos2d. I use many
I am developing a 2D iPhone game by using cocos2d. I need a countdown
What is the recommended way to do basic clipping with cocos2d? I am developing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.