Unity 5 iOS lag spikes

Hello,

I’m developing a simple 2d game which uses physics for collision detection. All colliders have a kinematic rigid body and they are all moved in Update step by step. Everything runs smooth but after some time (usually one minute but it depends) I get lag for a second.
I tried to run the profiler and the problem seems to be caused by “Overhead”. It makes 2 spikes of 35 and 50 ms.
I’m also setting the target framerate to 60 because by default it’s not smooth.
I’m testing on iPhone 4s via remote profiler, the lag also appears on iPhone 5s.

Any ideas what could cause these spikes and how to fix this?

Thanks.

The spike can happen when the profiler is running. Spikes can also happen during garbage collection, which could be case here, BehaviourUpdate is allocating 352 bytes each frame according to the screenshot. Try running a build and see if the spikes still occur. Also “lag” relates to network latency, not so much frame rate issues.