Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda