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 7522185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:26:54+00:00 2026-05-30T02:26:54+00:00

I am unsure about how to completely kill a node that uses graphics in

  • 0

I am unsure about how to completely kill a node that uses graphics in cocos2d-iphone.

So what exactly do I mean? Well, for instance, I have a CCTMXTiledMap. It uses some textures, right? Well, I no longer need to use this tiled map, so I kill it, and I assume that such textures a killed as well, and memory is freed.

I am using [[CCTextureCache sharedTextureCache] dumpCachedTextureInfo]; to get info about the textures currently held in memory.

    CCTMXTiledMap *map = [CCTMXTiledMap tiledMapWithTMXFile:@"myMap.tmx"];
    [self addChild:map z:0];
    [[CCTextureCache sharedTextureCache]
                             dumpCachedTextureInfo]; // I get 32MB usage.
    [self removeChild:map cleanup:YES]; // I assume this will "kill" the map.
    [[CCTextureCache sharedTextureCache]
                             dumpCachedTextureInfo]; // I STILL get 32MB usage

As you can see, removing the map from child doesn’t seem to truly kill the texture being used by it.

How exactly am I supposed to free memory then? I think that the same happens with CCSprites etc. Acoording to CCTextureCache, I just keep stacking memory until my app crashes.

Note: I know I could use something like [[CCTextureCache sharedTextureCache] removeAllTextures]; and clean everything up. But that doesn’t seem very efficient.

  • 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-30T02:26:56+00:00Added an answer on May 30, 2026 at 2:26 am

    CCTextureCache will only remove textures for which there exist NO references. I have not used the CTMXTileMap class myself, but maybe there are objects in there that reference the texture. The same happens with CCSpriteBatchNode. You must first remove the spriteFrames, then removeUnusedTextures from the cache, at which point the memory is reclaimed. Suggest you use removeUnusedTextures after removing the map as child.

    I dont see an explicit cleanup in CTMXTileMap, it is relying on dealloc to remove its objects that could reference the texture. Maybe (not certain about this), you should give a chance to the autorelease pool to release finally the map, before taking a measurement again.

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

Sidebar

Related Questions

I've always been confused/unsure about how .Net copies references. Let's say I have a
I'm unsure about the best practice for event handling/class design. I have a class
When I am unsure about some thing for a project, I usually use a
I'm making my first steps with unit testing and am unsure about two paradigms
I want place ads in my website, but I'm unsure about the common practices
I'm about to create a java crossword application but I am unsure of what
I have a class that converts images and videos to other formats. A number
I have a project idea, but unsure if using Python would be a good
I have a class built with Moose that's essentially a data container for an
I found this code over the internet but am unsure about how to use

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.