How do I relinquish all the memory that's tied to the current CBLReplication+CBLManager+CBLDatabase

37 views
Skip to first unread message

Alexander Selling

unread,
Feb 16, 2015, 8:51:51 AM2/16/15
to mobile-c...@googlegroups.com
Hi Jens,

I keep getting memory warnings during sync, and was hoping to be able to at least release all the memory that's currently being occupied by the replicator. What I've tried so far is closing all the databases that I have open and nilling out (and removing observers) my CBLReplication objects. This has no real observable effect when profiling on my iPad mini, the memory usage drops by like a mega byte or two and my iPad mini starts getting memory warnings at 145.3 MB which the replicator reaches within 30 seconds over wifi.

If I do close the CBLManager I hit an assertion saying that I shouldn't close the sharedInstance, but I don't see any other way to get rid of all the strong references?

I'm sure I'm missing something super obvious :)

Jens Alfke

unread,
Feb 16, 2015, 12:48:39 PM2/16/15
to mobile-c...@googlegroups.com
On Feb 16, 2015, at 5:51 AM, Alexander Selling <alexande...@gmail.com> wrote:

I keep getting memory warnings during sync, and was hoping to be able to at least release all the memory that's currently being occupied by the replicator.

Yikes, that’s bad. The replicator should not be using much memory, not more than 10mb or so.

What I've tried so far is closing all the databases that I have open and nilling out (and removing observers) my CBLReplication objects. This has no real observable effect when profiling on my iPad mini

Yeah, the replicator runs in a background thread that has its own database objects. The CBLReplication object you see is just a façade that communicates with the real objects (CBL_Puller and CBL_Pusher) on that thread.

It’s possible the memory usage is coming from app code that’s triggered by database-changed or document-changed notifications; or from LiveQueries, which are driven by those notifications. But it could also be a CBL bug.

— What version of CBL? Hopefully at least 1.0.3.
— How big are your documents? Attachment size shouldn’t matter, but do any of them have huge amounts of JSON?
— Does this happen with push, or pull, or both?
— How fast is the network connection between client and server? (I remember at one point there was a memory issue that only showed up with super-fast low-latency connections, because the puller could slurp in data faster than it could be saved to disk.)

Detailed investigation may require running Instruments to watch where memory’s being allocated.

—Jens
Reply all
Reply to author
Forward
0 new messages