Physics cpu overload problem

I replaced the page code with:

local PAGENAME = {}

 

function PAGENAME.creaPage()

end

 

function PAGENAME.destroyAll()

end

 

return PAGENAME

 

and when destroy the page call

package.loaded.PAGENAME= nil

 

But the cpu have again overload problem

physics.setPositionIterations( 50 )

… is way too high.  That is over 16 x the default, and I would expect that to crush a mobile device and even perhaps a desktop.

the higher that number is, the more physics iterations occur per frame.

Why do you feel the need to use such a high number?  i.e. What problem were you encountering with the default that you are you trying to solve with that high value?

@marcella,

Another thing I advise is: don’t use “physics.stop()” unless you absolutely want to destroy your entire physics world. If you intend to “resume” or use physics again sometime after, it’s almost always better to use “physics.pause()” instead. Basically, “physics.stop()” is a very powerful action, and often it’s too powerful, so use it with caution or with very intentional purpose.

Brent

Thanks for supports
I set physics.setPositionIterations(3) ad I use physics.pause() instead of physics.stop() but I still have the same problem.
It seems that _G.physics.start() add every times new operation on cpu.
Marco

Hi @marcella,

Why are you assigning physics to the “_G” space and then starting it multiple times? Just require physics in the module you need it and call “physics.start()” ( not"_G.physics.start()") and that will start the physics engine.

Take care,

Brent