Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
Firestore data loading memory overhead

My React Native app loads some documents from Firestore and stores them locally in AsyncStorage. Depending on the user's app usage, this document collection can become quite large. It might happen that the documents of a specific user grow into the dozens of megabytes, together (e.g. 500 documents of about 100kB each).

(It might be an antipattern to use Firestore for documents which are that big. However, most use cases are dealing with a small number of small documents. Still, we need to make the app ready for power users)

The app uses AsyncStorage as a local cache of the documents' data. If the data is already there, nothing gets loaded from Firestore (at least initially). If not, then the data is loaded from Firestore and stored in AsyncStorage (we cannot use Firestore's cache because we transform the data when loading it, and we need a deterministic cache).

What we noticed is, when loading the data from Firestore, we end up with a huge memory consumption, even after there was enough time for Garbage Collection to collect everything. When loading the data from AsyncStorage, the memory consumption is much lower, even though we have the same data in memory.

To make sure that this memory is still retained (i.e. that my observation does not depend on Garbage Collection timing), I loaded about a Gigabyte of Firestore data onto a device. There were several memory warnings, and judging by the memory consumption observed, GC was working hard to collect as much as possible, but the memory consumption was still several Gigabytes higher than compared to when the data was loaded from AsyncStorage.

It seems that the Firestore client either has

  • a huge memory overhead when loading documents from Firestore, and this memory overhead leaks and is not collected by GC
  • or some caching mechanism that leaves the query results in memory

Have I overlooked something? Is there some in-memory cache enabled by default? Does Firestore keep a copy of the data in memory to detect changes to the documents?

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!