I want to close the Realm instance in executeTransactionAsyncafter completion. The reason is that the main thread of my applications continues to freeze, I think the reason for this is because the background real instance does not close after execution is complete. See my code below:
realm.executeTransactionAsync(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
realm.copyToRealmOrUpdate(myData);
}
}, new Realm.Transaction.OnSuccess() {
@Override
public void onSuccess() {
Log.i("CB", "success");
}
}, new Realm.Transaction.OnError() {
@Override
public void onError(Throwable error) {
Log.i("CB", "error - " + error.getMessage());
}
});
}
Please view my comments. My application screen just goes black. The execution succeeds and onSuccess()is called, but I cannot access the scope instance executeto close it here.
Do you have any suggestions as to what I can try? Am I doing something wrong?
Thanks in advance.
EDIT
07-19 11:43:42.379 8146-8146/com.shortterminsurance.shortterm I/CB: success
07-19 11:43:43.258 8146-8152/com.shortterminsurance.shortterm W/art: Suspending all threads took: 33.234ms
07-19 11:43:43.266 8146-8156/com.shortterminsurance.shortterm I/art: Background partial concurrent mark sweep GC freed 476307(17MB) AllocSpace objects, 512(10MB) LOS objects, 40% free, 33MB/55MB, paused 7.261ms total 163.497ms
07-19 11:43:44.131 8146-8156/com.shortterminsurance.shortterm I/art: Background sticky concurrent mark sweep GC freed 408160(9MB) AllocSpace objects, 459(15MB) LOS objects, 35% free, 35MB/55MB, paused 10.287ms total 147.823ms
07-19 11:43:44.834 8146-8152/com.shortterminsurance.shortterm W/art: Suspending all threads took: 103.676ms
07-19 11:43:44.848 8146-8156/com.shortterminsurance.shortterm W/art: Suspending all threads took: 13.424ms
onSuccess. , execute - : (.