- Home /
Intermittent slow downs in Unity - unrelated to garbage collector
Every few seconds Unity slows down heavily, especially 'scripts' and 'others' which spike hard in the profiler, I thought it was garbage collection but it doesn't look like it.
][1]
I checked the script usages and there is no significant (if any) change between how much scripts were being used - furthermore I put the game in a situation where it flatout did not instantiate anything and the framerate still got jerky from time to time.
ANy ideas what I should be looking for to fix this?
Well then this is hard. How is your memory footprint looking? Do you have a memory leak by any chance and Unity runs out of memory and paging starts?
Hi, have you tried to call GC.Collect() yourself each frame so you can be sure it's not the garbage collection that causes those spikes ? Also, maybe you can play with the Time.timeScale to slow down your game and check if those spikes happen less often: then they would be more FixedUpdate()-related (physics maybe) than Update() related. To search for causes, I would also disable the maximum of scripts/objects, have a $$anonymous$$imal scene etc, until there is no more spikes, then add them back one by one to spot the cause.
Answer by Anxo · Oct 21, 2014 at 01:57 PM
Please post the code that is causing your spikes, The current information is very vauge but if I am going to shoot blind I would say take a look at the script and make sure you replace any GameObject.Find with GameObject.FindTag and if you have them in a loop, I would say find it before hand and store it in a variable before you get into the loop.
There is nothing in my code that is causing the spikes - the profiler is not indicating anything different about the spikes whatsoever as far as scripts are concerned, the graph is simply beco$$anonymous$$g much larger and that's it.
Your answer
![](https://koobas.hobune.stream/wayback/20220613165558im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
CPU being choked by GC.MarkDependencies 1 Answer
Invisible method costs? 0 Answers
Multiple Cars not working 1 Answer
ManagedHeap.ReservedUnusedSize 0 Answers
Distribute terrain in zones 3 Answers