Skip to content

[firebase_crashlytics] OutOfMemoryError inside CrashlyticsReportPersistence.writeTextFile on Firebase background thread #17861

@Milap-GSM

Description

@Milap-GSM

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Crashlytics, Core

Which platforms are affected?

Android

Description

We are seeing a Fatal OutOfMemoryError triggered inside Firebase Crashlytics’ internal crash-persistence pipeline.
The crash occurs when Crashlytics attempts to persist event files through:

CrashlyticsReportPersistence.writeTextFile() SessionReportingCoordinator.persistEvent()

This is happening in production, across multiple app versions and devices (mainly Samsung, Google).
Crashlytics is failing to allocate even small byte arrays (~128 KB), which suggests:

  • A possible memory leak inside Crashlytics’ persistence layer
  • Large or repeatedly queued reports
  • A threadpool backlog created by Firebase’s CustomThreadFactory
  • This is not caused by our app code—we do not write custom large Crashlytics events.
  • Occurs in background Firebase worker threads
  • Affects users running Android 13+ and even Android 15 (preview)

Reproducing the issue

This issue is not directly reproducible inside development, but visible consistently in production Crashlytics.

General pattern:

  • App runs normally.
  • Crashlytics captures an event and attempts to persist it.
  • Firebase background thread (CustomThreadFactory) tries to write event file.
  • Device has low free heap.
  • Crashlytics throws:
    java.lang.OutOfMemoryError: Failed to allocate 131584 bytes
    No custom steps on app side reliably trigger this; it appears internal to Crashlytics.

Firebase Core version

3.12.1

Flutter Version

3.27.3

Relevant Log Output

Fatal Exception: java.lang.OutOfMemoryError
Failed to allocate a 131584 byte allocation with 124824 free bytes and 121KB until OOM

at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:145)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:223)
at java.io.Writer.write(Writer.java:249)
at com.google.firebase.crashlytics.internal.persistence.CrashlyticsReportPersistence.writeTextFile(CrashlyticsReportPersistence.java:415)
at com.google.firebase.crashlytics.internal.persistence.CrashlyticsReportPersistence.persistEvent(CrashlyticsReportPersistence.java:140)
at com.google.firebase.crashlytics.internal.common.SessionReportingCoordinator.lambda$persistEvent$0(SessionReportingCoordinator.java:352)
at com.google.firebase.crashlytics.internal.concurrency.CrashlyticsWorker.lambda$submit$1(CrashlyticsWorker.java:96)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156)
at com.google.firebase.concurrent.CustomThreadFactory.lambda$newThread$0(CustomThreadFactory.java:47)
at java.lang.Thread.run(Thread.java:1119)

Flutter dependencies

Expand Flutter dependencies snippet
- firebase_core_platform_interface 5.4.2 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.24.0 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- firebase_crashlytics_platform_interface 3.8.4 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]

transitive dependencies:
- _flutterfire_internals 1.3.53 [collection firebase_core firebase_core_platform_interface flutter meta]
- firebase_analytics_platform_interface 4.3.4 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_analytics_web 0.5.10+10 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins]
- firebase_core_platform_interface 5.4.2 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.24.0 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- firebase_crashlytics_platform_interface 3.8.4 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
 

Additional context and comments

  • Crash appears across multiple app versions, so it’s not tied to a specific release.
  • We do not generate unusually large Crashlytics logs.
  • This appears strongly related to Crashlytics’ internal event queue / file writing.
  • A fix or investigation would help significantly as this is currently a production-level crash.
    If maintainers need additional logs, symbolicated events, I can provide them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    StaleIssue with no recent activityblocked: customer-responseWaiting for customer response, e.g. more information was requested.platform: androidIssues / PRs which are specifically for Android.plugin: crashlyticstype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions