using CCSpriteBatchNode issues

using CCSpriteBatchNode issues
0.0 0


i want to render a sprite on each tile of a 96X96 tilemap.
i want to use spriteBatchNode to get a high framerate and low memory allocation.
the high framerate is easy to achieve, but the memory allocation is much more than using a same size tilemap.
i don’t know where the problem is.

here is my code

    CCTexture2D *texture = NULL;
    texture = CCTextureCache::sharedTextureCache()->addImage("black.png");

    m_batchNode = CCSpriteBatchNode::batchNodeWithTexture(texture ,1000);
    m_nodeBoss->addChild(m_batchNode, kMaxZOrder);

    for (int i = 0; i < m_mapSize.width; i++)
        for (int j = 0; j < m_mapSize.height; j++)
            CCSprite* spriteBlack = CCSprite::spriteWithBatchNode(m_batchNode, CCRectMake(0, 0, 32, 16));
            spriteBlack->setPosition(CCUtility::positionAt(ccp(i, j)));

the code above causes 10M memory and the timemap just causes about 3M


I do not see any issues right away.
I’d suggest making the loop only create 1 sprite just to see if the memory is being allocated in the loop or outside of the loop.
If the memory usage is outside of the loop its either the texture or cocos2d-x itself.

Also, what platform are you using to get the memory information?
I’ve built a custom tilemap system as well and I get completely different memory usage info in Windows, iOS simluator AND iOS devices.
The iOS simluator uses the most memory (it adds 10+ megs sometimes), then the Windows build, and finally the iOS device reports the lowest memory usage (it can be many megs less than the others).