I am encountering a strange problem.
I noticed my firebase Android app was becoming a bit sluggish, so decided to profile it. To my alarm within a few minutes the memory usage had grown to 500MB. I paused the profiler to see what was going on, all the calls were coming from com.google.android.gms, when I looked at the CPU usage it was showing high use for the firebase database.
I tracked the problem down to the call ‘setPersistenceEnabled(true);’ on my database instance, if I turn this off performance returns and the RAM use is significantly lower.
When I start the app up I have a network connection, the RAM usage gets to 500MB within a few minutes
When I start the app up I have NO network connection, the RAM usage gets to 500MB within a few minutes as well.
I am not writing any data on startup, just reading some data from a particular node.
If I comment out all calls to the firebase database, and just leave stubs the RAM usage appears fine
If I reenable any one method that does any sort of database interaction, the RAM usage gets to 500MB within a few minutes
I almost think something has gone terribly wrong internally, and I should nuke the app and start again…
The Doc says
When you enable disk persistence, your app writes the data locally to
the device so your app can maintain state while offline, even if the
user or operating system restarts the app.
By enabling persistence, any data that the Firebase Realtime Database
client would sync while online persists to disk and is available
offline, even when the user or operating system restarts the app. This
means your app works as it would online by using the local data stored
in the cache. Listener callbacks will continue to fire for local
The Firebase Realtime Database client automatically keeps a queue of
all write operations that are performed while your app is offline.
When persistence is enabled, this queue is also persisted to disk so
all of your writes are available when the user or operating system
restarts the app. When the app regains connectivity, all of the
operations are sent to the Firebase Realtime Database server.
Does anyone have any ideas?