Hi,
I’m running into some pretty bad lag spikes (200 FPS down to 15 FPS) that occurs every so often at the beginning of my scene. Here’s the profiler with deep profiling:
I appears some sort of garbage collection is happening in AddMoney.Start(), related to the SceneManager. Here’s the relevant code from AddMoney:
void Start()
{
SceneManager.sceneUnloaded += OnChangeScene;
}
and
public void OnChangeScene(Scene current)
{
// Reset subscriptions.
addMoneyEvent = null;
}
where addMoneyEvent is a field declared as:
public static event Action<float> addMoneyEvent;
I can’t figure out why this lag spike is happening and what to do about it. It’s strange as well because I have other classes subscribing to SceneManager.sceneUnloaded too, but none of them are causing these huge lag spikes.
The 308 calls to AddMoney.Start() and 525294 calls to Delegate.Clone() seem extremely odd too, and I can’t quite figure out what’s going on.
It’s worth noting the lag spikes stop after a few dozen seconds.
Any ideas? Let me know if I can supply any other info.