I’ve been seeing OutOfMemory errors that crash my app for a while now. I haven’t really been able to consistently reproduce these errors, but I can see them negatively affecting my stats in the store.
After copy-pasting my code to AI, it identified an issue called object churning. It’s when an object is allocated a lot, in my case for me, it’s calculations every frame using a Vector2.
The fix was very simple. Create a temporary Vector2, and just populated it with the values I need when I need to make calculations instead of creating a new one.
With this change, I’ve also noticed a significant reduction in stuttering of animations too.
The moral of the story is, when something is being done every frame, think hard on what objects are being allocated, or you might run into intermittent issues depending on the device memory capacity.
Leave a Reply