Note that there are some explanatory texts on larger screens.

plurals
  1. POcocos2d 2.0+ Scale Bug || Performance drop || Endless memory allocation
    primarykey
    data
    text
    <p>Has someone of you ever noticed that scaling a sprite up to more than 100% can cause the render time per frame to increase and never go down again?</p> <p>I've set up a test project based on a cocos2d 2.0 template (I also tested it with 2.1 and it also does happen). When touching the screen (testing with an iPad 3) it creates 100 sprites that are scaled by 1.5 When there are 5000 it removes them all. When they get removed the render time very often stays at 0.016. By double tapping the home button (causing some interrupt to happen) you can make it go back to 0.001 (when there are no sprites). I did a lot of testing when and how to cause this and I came to the conclusion that it only happens when scaling something. </p> <p>While in 0.016 "mode" there is a constant memory increase (look at the allocations tool) and as soon as you double tap the home button it goes down again slowly. These allocations come from the gyroscope / accelerometer code that I put in there. When in 0.001 "mode" it works fine but as soon as the render time shows 0.016 memory gets allocated endlessly and it is never freed.</p> <p>Especially with really big scalings this thing can be achieved easily. Does anyone have an idea how to fix this?</p> <p>This does happen when touching the screen in my test project. You can download it here: <a href="https://dl.dropboxusercontent.com/u/40859730/RenderTimeIssue.zip" rel="nofollow">https://dl.dropboxusercontent.com/u/40859730/RenderTimeIssue.zip</a></p> <pre><code>static int spriteCount = 0; - (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event { for (int i = 0; i &lt; 100; i++) { CCSprite *icon = [CCSprite spriteWithFile: @"Icon.png"]; [icon setPosition: ccp(arc4random() % 1000, arc4random() % 1000)]; [self addChild: icon]; icon.tag = spriteCount; // this line causes the "0.016 bug", comment it out and the frame rate does go back to 0.001 when 5000 sprites are reached icon.scale = 1.5f; // while scaling up more than 1.0 causes the problem, scaling down does not spriteCount++; } if (spriteCount &gt;= 5000) { for (int i = 0; i &lt; spriteCount; i++) { [self removeChildByTag: i cleanup: YES]; } spriteCount = 0; } return YES; } </code></pre> <p>EDIT: Here are some images that show the memory increase: <a href="http://imgur.com/a/Jy70a" rel="nofollow">http://imgur.com/a/Jy70a</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload