Sunday, January 14, 2024

Memory Management Mayhem

As I was testing the app, I noticed that as I'm making many changes to streamline how it uses memory and tweaking processes, the app was still starting running nicely, then slowly degraded over time. So, on Friday, I got into "fix-it" mode, started running various tests and profiling the app to see what was going on.

First up, I found out that by placing nice backgrounds on the login and landing pages, I was using up 70 megabytes (no, really, seventy megabytes) of Androids small allotment of memory to show these as the Activity was sort of sitting there off-screen somewhere. So, that got resolved to only show the images when the Activity was visible. Bam. Seventy memory back thanks!

Next up, turns out that following some basic docs on how to show/create Activities (or, in game terms, how to open up a character screen, inventory and skill trees) actually causes memory leaks, which is a terrible way of saying that the meagre memory you start with is getting wasted on more trash that's not needed. That one was quite a bit harder to fix, as it needed a reasonable re-write of the was I call certain activities, but also changing notification methods completely (or again, in game terms - when you picked up an item from monster loot, it needed to move the icon from the "loot" pile, into the "Inventory" pile. Wham, no memory leaks.

Finally, testing again.

The Android emulator I have still seems to be doing a lot of pause-y stuff, but I gave it a run on my actual phone... and it ran smooth as smooth can be. Glorious success. I'll do more testing, but I am really really happy and confident that this is squarely back in the fast lane now.

No comments:

Post a Comment

New Abilities, Ability Functionality and Spells

It's been a few days since I posted, but I have been super busy working on iterative builds here to run through my own testing, and that...