Performance problems with adding and removing static bodies

First of all I must say thank you for such a great tool, but "saddly" i have a small problem... i hope:)

Platform: iphone and cocos2d.

I have cca 200 static bodies that have same velocity and one dynamic body. Static bodies are entering and than leaving the screen(play area). Imagine a a game where you are flying through a cave with stones as obstacles.

In my first attempt i was creating "world->CreateBody()" obstacles before they entered on screen and than destroy "world->DestroyBody()" them. The problem was that the game randomly started to jiggling (FPS dropped from 60 to 20,30) for a second or two. Here i suspect garbage collector. It happened more often when there were more (around 20 obstacles) on the screen.

Than i tried creating all the obstacles at the beginning of the level and put them to sleep SetAwake(NO). Right before they enter to the screen i wake them up. The results were better, jiggling almost dissapered, but FPS drops to 30,40. I have also tried to use SetActive() method. FPS was better, but the jiggling come back and to occured more often than in previous try(SetAwake()).

Now the questions are: Which solution do you recommend? What is the proper/faster way for adding and removing objects? What is the key difference between awake and sleep flag. And do you have anyideas how could i improve performances?

Thank you.
First, make sure that you are using the latest Box2D. It self balances the b2BroadPhase dynamic tree from what I understand. This can make a huge difference in the stability of your framerates. Secondly, and this is painful, but if you insist on 60fps, then you must do away with Cocos2D entirely. It depends heavily on Objective C, and my own experience lines up with John Carmack's view that Objective C is too slow for the iPad 1. I wrote a C++ game library with thin wrapper classes that update the accelerometer and touches.
Hey,
thanks for info. Yes i have the lastest Box2D.
Huh, going away from cocos2D would be too much. I have already written almost all the code. I want just to polish and optimize some things if possible. The last chance will be leaving cocos2D:)
What do you think about flag awake vs active or is there any other possibility? Do you have any examples, links of how to properly integrate C++ libraries in the code (cocos2D)?

Original thread: https://box2d.org/forum/viewtopic.php?t=7988