- Home /
Graphics Chopping
My framerate is good, at 40 - 80 fps, but once in a while it drops down to 3 - 5 fps, for no apparant reason. It is not caused by errors, etc., and my stats seem okay.
So I can't understand what's wrong with it. Anyone have an idea?
Answer by Cool Dave · Nov 12, 2012 at 10:31 PM
Figured out the problem. I had five large objects rotating to face the camera using a script called LookAt2D.js, which does the turning in a fixedUpdate. Somehow, this caused the stated behaviour.
Thanks anyways for the answers everyone.
Answer by shaderop · Sep 26, 2012 at 09:05 PM
It could be due to the garbage collector kicking in. Check the profiler for calls to `GC.Collect()`.
He's probably right. And if he's right you're probably allocating/releasing to much. Try to make an object pool to reuse your objects.
I'm not instantiating or destroying anything, although I do have those funtions in some of my scripts. Am I misunderstanding you?
Everytime you create an object (not necessarily a GameObject, can be anything) it uses some memory. When you're not using anymore (cause you destroyed it or no variable is referencing it) it will me marked to be collected. From time to time (you have no control over it) the Garbage Collector will remove from the memory everything that is marked. If it have too much to remove it can cause the FPS drops that you see.
@Cool Dave: Profiler is a a pro-only feature, but I thought you had Pro because of the dark background in the picture you posted. $$anonymous$$y mistake :)
Answer by Owen-Reynolds · Sep 27, 2012 at 03:51 AM
The Unity Editor sometimes, very intermittently, get pauses and stutters during a run, just for being the Editor. It's keeping extra stats, running the Inspector and Hierachy windows ... . I've run the exact same stuttering projects in a real Build and had it all go away (then come back in the Editor again.)
Answer by Bunny83 · Sep 27, 2012 at 12:43 PM
The worst thing you can do is to have a Debug.Log (or print) statement in Update. It will kill your framerate. Are you sure you don't spam Debug.Logs? In a build Debug.Logs in Update aren't that bad, but keep in mind they get written to the log file. When one log has about 500 bytes and you run at 60 fps, that's a lot per minute (~1.5MB / min) ;)
I know some games that create huge logs when you play for a while. In my opinion that's not an acceptable behaviour ;)
Your answer
Follow this Question
Related Questions
GPU Graphics.blit huge time on android 0 Answers
Game skips at specific points in level (not garbage collector) 0 Answers
Huge permorance difference - Help?! 0 Answers
Performance/framerate issue 0 Answers
Low fps with only a few characters? 2 Answers