开发者

Android application pauses - slow garbage collection or SQLite performance problem?

I have an Android application that communicates with a Jersey webservice using JSON. The received data is stored in a SQLite database on the Android device.

According to DDMS, the heap size is around 6MB, with around 2MB free. However, the application 'pauses' (not asking new data from the webservice) after receiving some amount of data. Then I see the garbage collection being triggered and the application continues. Manually triggering System.gc() seems to have no effect, or even degrade the performance.

My question is: is the garbage collection the cause of the pausing, or is writing to the SQLite database on the Android device relatively slow?

开发者_如何学Go

update: Android version is 2.3.3


Writing to a SQLite database is slow, because file I/O is slow, because flash is slow. More specifically, SQLite transactions are slow, because transactions write data to flash, and flash is slow. If you are performing multiple SQL operations in rapid succession, consider wrapping them in your own transaction.

Beyond that, use Traceview to identify where your time is being spent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜