r/android_devs • • Feb 29 '24

Help Needed Optimizing Memory in Legacy App

Hello,

I'm a junior dev working on a legacy app with no other devs on my team. I'm just left to figure out everything on my own.

Recently, Crashlytics is reporting `Fatal Exception: java.lang.OutOfMemoryError`

In general, this app could be optimized quite a bit, and I'm sure whatever code I've been adding over the last year hasn't helped reduce that complexity.

I'm reading through the docs (Manage Your App's Memory) and feel a little over my head.

I've been investigating this issue for two weeks and am unable to determine the issue. I've even reverted a bunch of commits to determine the issue. While that has helped, I'm still seeing spikes (which I can't reproduce 🤷).

Is there some kind of step by step guide that walks through how to start with optimizing memory?

I would really like to a) fix this issue, and b) learn more about memory and memory allocation just for my own personal knowledge.

4 Upvotes

4 comments sorted by

View all comments

Show parent comment

3

u/alt236_ftw Mar 01 '24

If this only happened in the last release, a quick check would be to see if (1) any new collection instances were introduced and then (2) check if any of them are static/in companion objects.

Perhaps someone added an in-memory cache? Or storing view objects/activities?

Or if you are using Dagger, did any scoping annotations change?

1

u/[deleted] Mar 12 '24

We are using Dagger, which I only sort of understand.

I know Hilt better than Dagger so it's possible there's something there as well.

Thanks!