Unity3D crashes when stopping from Debug mode: Is there a way to help it manage memory?

So, to explain, in the Unity Editor I can play my game just fine. A little bit of lag because it doesn’t cooperate with separate threads very well, but nothing that worrisome. However when I exit debugging from my game scene, it crashes.

Now, the reason is no mystery to me. I allocate massive amounts of memory during the game. I’m talking potentially over a million arrays.

An obvious solution would be to reduce memory load, which I am doing. But since the issue isn’t present in the build version, its not exactly a high priority.

That being said, having to reopen unity every time is a bit of a pain. I’m curious if there is a way to help the Unity Editor to properly close out the game. In C++ it would be deconstructors, but obviously this is C# with garbage collection. But if I could somehow detect the “close everything” call as it were, I would be able to at least attempt to deallocate the memory without it crashing.

If there is no way, that is okay. Just thought I’d ask if someone knew a way.

Possibilities are you are using to much Coroutines which is consuming lots of threading power.
Second is may be yu are returning some array that is big in size.