Couchbase-lite-ios 2-node cycle in Memory Debugger

mobile

#1

I’ve been doing a little memory debugging on an app that uses couchbase-lite-ios, and I’ve noticed that Xcode pretty consistently suggests that there’s a two-node cycle between CBLRestPuller and CBLRemoteSession, and that leads to leaks of anything either class references.

I don’t know the couchbase-lite-ios internals well enough to suggest that this is truly a problem. It might be that Xcode’s analysis catches a potential problem that, in reality, if I dug into the code in great detail, I would be able to understand that it isn’t a problem.

Having said that, since I’m seeing it, I thought I’d point it out and let those of you who do know the code decide if it’s a problem. By way of example:


#2

Thanks! I confirmed that this does cause a leak (neither object clears its reference to the other when the replication stops), and filed an issue.


#3

In case these are similarly helpful – I don’t find filing them as issues, but since I feel like they should be investigated more deeply than I have done before deciding that they’re bugs, this feels like the right place to post 'em.

The cycles with CBLManager and CBLDatabase seem to be database holding a manager reference and manager holding a dictionary of databases, which I can inspect:

Printing description of $0:
{
cbase = “CBLDatabase[<0x170127120>cbase]”;
}


#4

Yeah, the Manager⟵⟶ Database references are intentional. (I don’t remember why the up-reference from Database can’t be weak, but I know there was a reason for it, unless it’s just because the design predates ARC.) The links are explicitly broken when a Database or the Manager is closed.