diff --git a/Firestore/core/src/firebase/firestore/local/leveldb_remote_document_cache.h b/Firestore/core/src/firebase/firestore/local/leveldb_remote_document_cache.h index 536d74c1d33..99bf754b87a 100644 --- a/Firestore/core/src/firebase/firestore/local/leveldb_remote_document_cache.h +++ b/Firestore/core/src/firebase/firestore/local/leveldb_remote_document_cache.h @@ -57,7 +57,8 @@ class LevelDbRemoteDocumentCache : public RemoteDocumentCache { FSTMaybeDocument* DecodeMaybeDocument(absl::string_view encoded, const model::DocumentKey& key); - FSTLevelDB* db_; + // This instance is owned by FSTLevelDB; avoid a retain cycle. + __weak FSTLevelDB* db_; FSTLocalSerializer* serializer_; }; diff --git a/Firestore/core/src/firebase/firestore/local/memory_mutation_queue.h b/Firestore/core/src/firebase/firestore/local/memory_mutation_queue.h index 463439e9331..b8113c70dda 100644 --- a/Firestore/core/src/firebase/firestore/local/memory_mutation_queue.h +++ b/Firestore/core/src/firebase/firestore/local/memory_mutation_queue.h @@ -111,7 +111,8 @@ class MemoryMutationQueue : public MutationQueue { */ int IndexOfBatchId(model::BatchId batch_id); - FSTMemoryPersistence* persistence_; + // This instance is owned by FSTMemoryPersistence; avoid a retain cycle. + __weak FSTMemoryPersistence* persistence_; /** * A FIFO queue of all mutations to apply to the backend. Mutations are added * to the end of the queue as they're written, and removed from the front of diff --git a/Firestore/core/src/firebase/firestore/local/memory_query_cache.h b/Firestore/core/src/firebase/firestore/local/memory_query_cache.h index 706b8f40401..ac34fca078e 100644 --- a/Firestore/core/src/firebase/firestore/local/memory_query_cache.h +++ b/Firestore/core/src/firebase/firestore/local/memory_query_cache.h @@ -95,7 +95,9 @@ class MemoryQueryCache : public QueryCache { void SetLastRemoteSnapshotVersion(model::SnapshotVersion version) override; private: - FSTMemoryPersistence* persistence_; + // This instance is owned by FSTMemoryPersistence; avoid a retain cycle. + __weak FSTMemoryPersistence* persistence_; + /** The highest sequence number encountered */ model::ListenSequenceNumber highest_listen_sequence_number_; /** The highest numbered target ID encountered. */ diff --git a/Firestore/core/src/firebase/firestore/local/memory_remote_document_cache.h b/Firestore/core/src/firebase/firestore/local/memory_remote_document_cache.h index 85bddc37472..e0f3cda628a 100644 --- a/Firestore/core/src/firebase/firestore/local/memory_remote_document_cache.h +++ b/Firestore/core/src/firebase/firestore/local/memory_remote_document_cache.h @@ -62,7 +62,8 @@ class MemoryRemoteDocumentCache : public RemoteDocumentCache { /** Underlying cache of documents. */ model::MaybeDocumentMap docs_; - FSTMemoryPersistence *persistence_; + // This instance is owned by FSTMemoryPersistence; avoid a retain cycle. + __weak FSTMemoryPersistence *persistence_; }; } // namespace local