RPC on android causes GC_EXPLICIT

2019-09-06 06:15发布

问题:

I need to synchronize my local sqlite database with a remote mysql database. I'm testing different XMLRPC and JSONRPC projects to do so.

I send a packet containing all entries that arn't synced yet for each table.

When these RPC projects are parsing the data logcat is filled with GC_EXPLICIT.

GC_EXPLICIT means that the garbage collector has been explicitly asked to collect, instead of being triggered by high water marks in the heap. Happens all over the place, but most likely when a thread is being killed or when a binder communication is taken down. ~ Robert

I tried to modify a XMLRPC project to perform my desired actions right after an entry is read from the packet and then use the same object variable to instantiate the next entry.

This however does not solve the collect requests to the garbage collector.

Any idea? tips? suggestions?

回答1:

I solved my problem a couple days ago.

I'm using the Android JSON RPC module made by Alex (project).

I removed the part where the module parses the JSON. And created my own parse routine using regex. The module also performs SQLite query's instead of creating JSON objects.

Another thing I changed is that the module will accept and receive multiple packets with a maximum of 1000 entries.

The code is extreemly fast, it took 30 minutes to synchronize 3000 entries, now it only takes 3 minutes. The reason why I'm posting this information instead of the code is because the code is very project specific.

Information about how to loop and why not to allocate over 1000 objects is described in the android performance document.