- Home /
Laggy gameplay and occasional crashes
This problem revealed itself all of a sudden. When we switch scenes from scene A to scene B, the scene B gets really laggy. FPS is around 50, but about every second or so it sinks down to near-zero. Profiler doesn't show anything when these peaks happen since the profiler doesn't keep tracking when this lag occurs, it kinda "skips" the lag part.
I've tried to print out the object counts using both Resources.FindObjectsOfTypeAll() and Object.FindObjectsOfType() functions, and there is no changes in the object / component amounts. I've checked the code and there is little to no arrays in use, and when they are, they are released as expected.
After spending about 30 seconds or so in the laggy scene, I get a GC fatal error saying "too many heap sections". It relates to garbage collection, which in turn relates to memory leaking. It's funny though that if I start the game directly to the laggy scene, it doesn't lag at all, only if I change the scene to it.
Yes ofc, but there is a couple of objects (game character, networking script etc.) that stay between scene changes (DontDestroyOnLoad()).
It works nicely in scene 1. I'm starting to think it's our network library (Badumna) which causes the lagginess, but I'm still not sure. How should I try to find out if it's Badumna or something of our own code?
Isolate and disable any DonDestroy objects one by one to find out what is causing you the headaches.
Answer by Unamine · Jun 29, 2011 at 11:08 AM
Go disabling or removing objects, including how you said the player and the network to discover what causes the lag, can also be an assembly error in the script loops or doing anything that really overload the system, make sure there are many objects or some models with MANY polygons in the scene.
Also try increasing your virtual memory, here I had NBA 2K11 is was too much lag, increased my virtual memory and ran smooth.
I hope I helped ^^
Your answer
Follow this Question
Related Questions
Default-Diffuse material leak - how to find source? 2 Answers
Player object carried from scene to scene 1 Answer
Move camera upon button press 0 Answers
Why is Unity taking up hdd space when I'm using it? 0 Answers
memory management strategy 0 Answers