内存分配-UI卡住/挂起-网络通话(Rx2AndroidNetworking)和在SQLite中插入记录(ActiveAndroid)

我在我的项目中使用Rx2AndroidNetworking从服务器JSON对象列表中获取getObjectListObservable数千条记录,这些记录涉及3个表的SQLite数据库的150多个属性,我必须重新同步(插入) activeAndroid ORM将数据存储到SQLite表中。

在执行Rx2AndroidNetworking.get方法时,logcat中将显示以下日志。

D/Loginactivity: onCompleted: only_login
D/Loginactivity: onComplete: before_executing_the_resyncing_code
D/Loginactivity: InsertData: before_Rx2AndroidNetworking_GetPatients
I/art: Do partial code cache collection,code=57KB,data=58KB
I/art: After code cache collection,code=56KB,data=57KB
I/art: Increasing code cache capacity to 256KB
I/art: Background sticky concurrent mark sweep GC freed 12747(2MB) AllocSpace objects,0(0B) LOS objects,11% free,17MB/19MB,paused 12.598ms total 37.164ms

在执行public void onNext方法时,logcat中将显示以下日志。

D/Loginactivity: onNext: resyncing_insert_data_in db
I/art: Do full code cache collection,code=125KB,data=101KB
I/art: Starting a blocking GC JitCodeCache
I/art: After code cache collection,code=69KB,data=44KB
I/art: Do partial code cache collection,code=81KB,data=80KB
I/art: After code cache collection,code=80KB,data=80KB
I/art: Increasing code cache capacity to 512KB
I/art: Compiler allocated 6MB to compile void .onNext(java.util.List)
I/art: Compiler allocated 8MB to compile void .onNext(java.util.List)

在执行网络调用并将数据插入SQLite时,我的应用程序的UI卡住了。我的应用程序想从操作系统获取内存,但是设备(具有3 GB RAM的联想TB-X704L)无法为我的应用程序分配超过64 MB的内存(屏幕快照随附于此)。

内存分配-UI卡住/挂起-网络通话(Rx2AndroidNetworking)和在SQLite中插入记录(ActiveAndroid)

诊断问题并提出解决方案。

maige216 回答:内存分配-UI卡住/挂起-网络通话(Rx2AndroidNetworking)和在SQLite中插入记录(ActiveAndroid)

您在哪个线程上执行sql操作?尝试在单独的工作线程上移动sql操作。

本文链接:https://www.f2er.com/3168649.html

大家都在问