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

  • Home
  • SEARCH
  • 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 7687819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:47:19+00:00 2026-05-31T19:47:19+00:00

I load my animated character with a huge texture this way: [[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@MyFile.plist]; And

  • 0

I load my animated character with a huge texture this way:

[[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@"MyFile.plist"];

And later, when I am no longer using the character, I release memory using:

[[CCSpriteFrameCache sharedSpriteFrameCache]removeSpriteFramesFromFile:@"MyFile.plist"];

And also:

[[CCTextureCache sharedTextureCache]removeTextureForKey:@"MyFile.png"];

Just to be sure.

I do that because the texture it uses consumes a lot of memory, so I make sure I dispose of it so my app doesn’t crash. Is the above code correct?

Anyway, here is the actual problem: I eventually load my character again, and dispose of it again. Eventually, after a couple revives and kills, the app crashes. The log says nothing about it, so I can just suspect that it was due to memory – that’s why I assumed that I wasn’t disposing the texture properly.

I do need to create and dispose the character’s texture. I can’t afford to have it preloaded in the game.

  • 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-31T19:47:21+00:00Added an answer on May 31, 2026 at 7:47 pm

    I usually use the brute force approach as follows:

        [[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];
        [[CCTextureCache sharedTextureCache] removeUnusedTextures];
    

    at specific moments in the game flow. It is not too too costly to have coco scan its arrays, in the grand scheme of things. As in your case, in my current game i must load and ditch. CCTextureCache has CCLOG’ing that permit you to witness whether the removal actually occurs when you expect it, or close to it (autorelease has its quirks). If not, you are probably retaining some handle to the texture somewhere, a sprite, batch node, an CCAnimation, or an action.

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

Sidebar

Related Questions

i load a class using Class.forName(klassname,false,loader) After this i create an instance using klass.newInstance();
I have a favorites plist file when I try to load it like this
I am using the below to load a jQuery animated graph, however, there are
In situations where a browser is under intense load I find that animated gifs,
I load data into my grid using a WCF service. When a user clicks
I load a UIWebView from a string in a navigation based app. I'm using
I wonder how can I load animated gif to picturebox and than delete original
Why do simple animated gif images take so long to load before they start
What is the recommended animated model format that a game programmer would load in
I'm getting this error when I try to load another view: 2012-02-21 20:31:38.477 App

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.