Push filter on CouchbaseLite Android is memory consuming

Using Couchbase Lite Android 1.4.0.

I have a bucket of ~20.000 documents that is synced to and from my android device (pull & push replications).
I saw that when the continous replication of this bucket has started, the memory of my Android application is increasing drastically (from ~100MB to ~250MB).

I found out that the bad guy making my memory growing like this seems to be the ReplicationFilter I set to the push replication (I tried with and without the filter and we clearly see a difference inside the memory).

My filter is basic:

	final String id = revision.getDocument().getId();
	return !(Objects.equal(id, Config.COUCHBASE_BUCKET_KEY_DOC_ID) || Objects.equal(id, Config.COUCHBASE_SYNC_GATEWAY_KEY_DOC_ID));

I saw that the memory decreased to ~150MB after several seconds but when I don’t set the filter the memory stick at ~110MB.

I didn’t see the impact of this increasing memory directly on the application but it doesn’t seem normal to me that the memory grows so much. Does someone has some explanation for me?

Thank’s for reading.

@hideki, any ideas about this?

CBL Android 1.x does not check each document size. I assume this peak memory consumption is caused by each document size and number of the updated documents. I did not notice replication filter could consume memory.

Hi! By investigating it doesn’t seems to be a Couchbase related issue but an app related one. I still didn’t resolved it but I managed to add a filter without getting this memory peak.

I’ll inform you if I find out what is the real cause behind this issue.

I’m actually running into this exact same issue currently in my Android app and it’s causing OOMs while reindexing. If there’s no Push Replication Filter, Memory Usage is at ~75MB, but once I add the Push Replication Filter, memory usage jumps up to ~350MB and OOMs occur on some lower-end devices

Do you guys have any idea what could be causing this? I end up seeing many Waiting for a blocking GC Alloc in my logs.

This is with Couchbase Lite 1.4, like the previous messages in this thread?
Have you done any heap profiling to see where the memory is going?

@jens so we currently use a modified version of couchbase that is basically 1.2.1 with a couple of commits from 1.3.0.

Most of the memory usage is going to LinkedHashMap$LinkedHashMapEntry and HashMap$HashMapEntry[] This all seems to happen during deserializing.

That in itself doesn’t say much; if you can get the backtraces of the calls that allocate the most, it’d be more informative.

However, I don’t think we’re going to be able to offer much help, as you’ve got nonstandard code, the versions you’re using are all old enough that we’ve stopped officially supporting them, and I don’t believe there are any development engineers currently at Couchbase who know the CBL Java 1.x sourcebase well. (2.0 was a nearly complete rewrite.)