- Home /
1-3 second "spikes" (not GC?) on Android
I'm experiencing 1-3 seconds long cpu "spikes" on my Samsung Galaxy Nexus every now and then. It goes from around 45 fps to around 30 fps for 1-3 seconds even while having the game paused with Time.timeScale = 0.00000001f. It's not a single script that runs slower, it's everything from rendering, overhead etc. Also, since the game is paused all the other profiling such as draw calls, audio sources etc are flatlined.
I've made a script that checks if garbage collection is run (on update check if heapSize is less than heapSizeLastFrame) but there's no collection before, during or after the spikes. They seem totally unrelated. Maybe you can't check garbage collection like this?
I have no other apps running on the phone.
Has anyone got any idea what this could be?
Need more info. What exactly happens in stats button when this happens. Do you have access to the profiler?
I have access to the profiler (connected to the android device). If you mean the stats button I think about it's the editor and the problem is on the android device...
So where do the spikes occur according to the profiler?
Sorry but what do you mean by where? Every function in the profiler is slowed down, from Render to Overload. So it's no specific function. It comes and goes a bit randomly. I can even happen when the game is paused (timeScale=0.0000001f).
In profiler click on the spike and read off what processes are taking the biggest ms to complete.
Answer by SilentSin · Oct 04, 2013 at 01:30 PM
If you have the pfiler, we need more info.
If you don't have the profiler, how can you say its not a script that is causing it.
And no, Time.timeScale = 0.00000001f is not paused, why would you think that. Time.timeScale = 0 is paused. And even while paused, I believe everything still gets Update() calls, just with Time.deltaTime as 0 (or in your case, a very very small number). Do some debug logging to verify if this is the case.
I use timeScale=0.000001f to be able to update NGUI panels when pausing the game from the players point of view, not programmatically. And programmatically it means that no new gameobjects are spawned etc.
Like my description says there's not much to read out of the Profiler. In some cases all other profiling is flatlined during the spike (audio sources, draw calls etc).
Almost all functions in the CPU Usage profiling slows down during the spike so there's no telling which one is the "theif". So there is no specific function that stands out.
I have no clue what you mean by not programatically and programatically. And no, it doesn't mean that no new game objects are spawned, it just means they'll take a really long time to spawn. Is there something wrong with timeScale = 0?
Turn on deep profiling (I think that's what its called). It lets you dig into everything to see exactly what is causing the slowdown.
Forget about the timescale. It just needs to be more than 0 for NGUI to update the graphics in the pause menu.
Deep profiling is on and there's still just an overall slowdown.
Interesting, I would have thought NGUI would support actual pausing, but whatever.
If every single function is taking longer, then its something else on the phone.
Get a task manager and kill every running app immediately before running yours and see what happens.
If that doesn't help, you'll need to test on s different device.
Your answer
![](https://koobas.hobune.stream/wayback/20220613115311im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Standard Assets(Mobile) too expensive(CPU)? 0 Answers
Event System and GVR Event System 0 Answers
Profiling empty project, but there is activity! 1 Answer
What is VFP? 1 Answer
Can Apps ask for CPU power? 1 Answer