Skip to content

Firestore OOM crash when device still has 3GB free memory #7973

@fanwgwg

Description

@fanwgwg

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository. If you have a general
question, need help debugging, or fall into some other category use one of these other channels:

  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the
    firebase-talk google group.
  • For help troubleshooting your application that does not fall under one of the above categories,
    reach out to the personalized Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: Android Studio Panda 2 | 2025.3.2
  • Firebase Component: Firestore
  • Component version: com.google.firebase:firebase-bom:34.11.0

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

Unsure how to reproduce. We're only observing some crashes from this.

Stacktrace

  Fatal Exception: java.lang.OutOfMemoryError: Firestore (26.1.2) ran out of memory. Check your queries to make sure they are not loading an excessive amount of data.
       at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3(AsyncQueue.java:536)
       at android.os.Handler.handleCallback(Handler.java:997)
       at android.os.Handler.dispatchMessage(Handler.java:111)
       at android.os.Looper.loopOnce(Looper.java:237)
       at android.os.Looper.loop(Looper.java:325)
       at android.app.ActivityThread.main(ActivityThread.java:10404)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:635)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:970)
Caused by java.lang.OutOfMemoryError: Failed to allocate a 16 byte allocation with 3783120 free bytes and 3694KB until OOM, target footprint 536870912, growth limit 536870912; giving up on allocation because <1% of heap free after GC.
       at com.google.firebase.database.collection.ImmutableSortedSet.insert(ImmutableSortedSet.java:87)
       at com.google.firebase.firestore.local.ReferenceSet.addReference(ReferenceSet.java:57)
       at com.google.firebase.firestore.local.ReferenceSet.addReferences(ReferenceSet.java:64)
       at com.google.firebase.firestore.local.LocalStore.lambda$notifyLocalViewChanges$7(LocalStore.java:614)
       at com.google.firebase.firestore.local.SQLitePersistence.runTransaction(SQLitePersistence.java:218)
       at com.google.firebase.firestore.local.LocalStore.notifyLocalViewChanges(LocalStore.java:608)
       at com.google.firebase.firestore.core.SyncEngine.emitNewSnapsAndNotifyLocalStore(SyncEngine.java:711)
       at com.google.firebase.firestore.core.SyncEngine.handleRemoteEvent(SyncEngine.java:404)
       at com.google.firebase.firestore.core.MemoryComponentProvider$RemoteStoreCallback.handleRemoteEvent(MemoryComponentProvider.java:120)
       at com.google.firebase.firestore.remote.RemoteStore.raiseWatchSnapshot(RemoteStore.java:588)
       at com.google.firebase.firestore.remote.RemoteStore.handleWatchChange(RemoteStore.java:499)
       at com.google.firebase.firestore.remote.RemoteStore.access$100(RemoteStore.java:62)
       at com.google.firebase.firestore.remote.RemoteStore$1.onWatchChange(RemoteStore.java:190)
       at com.google.firebase.firestore.remote.WatchStream.onNext(WatchStream.java:114)
       at com.google.firebase.firestore.remote.WatchStream.onNext(WatchStream.java:38)
       at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.lambda$onNext$1(AbstractStream.java:126)
       at com.google.firebase.firestore.remote.AbstractStream$CloseGuardedRunner.run(AbstractStream.java:67)
       at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.onNext(AbstractStream.java:113)
       at com.google.firebase.firestore.remote.FirestoreChannel$1.onMessage(FirestoreChannel.java:162)
       at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:667)
       at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:654)
       at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
       at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:520)
       at java.util.concurrent.FutureTask.run(FutureTask.java:317)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:348)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1154)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:652)
       at com.google.firebase.firestore.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:235)
       at java.lang.Thread.run(Thread.java:1564)

In Firebase crashlytics console, the device is shown with 2.99 GiB RAM free.

Image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions