Garbage collect before/after sync

pull/214/head
M66B 12 months ago
parent 9769e774ea
commit 01383680d2

@ -173,7 +173,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
executor.submit(new Runnable() { executor.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
Helper.gc(); Helper.gc("Boundary start");
int free = Log.getFreeMemMb(); int free = Log.getFreeMemMb();
Map<String, String> crumb = new HashMap<>(); Map<String, String> crumb = new HashMap<>();
@ -228,7 +228,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
} finally { } finally {
state.queued.decrementAndGet(); state.queued.decrementAndGet();
Log.i("Boundary queued -" + state.queued.get()); Log.i("Boundary queued -" + state.queued.get());
Helper.gc(); Helper.gc("Boundary end");
crumb.put("queued", Integer.toString(state.queued.get())); crumb.put("queued", Integer.toString(state.queued.get()));
Log.breadcrumb("Boundary done", crumb); Log.breadcrumb("Boundary done", crumb);
@ -994,7 +994,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
ifolder = null; ifolder = null;
imessages = null; imessages = null;
Helper.gc(); Helper.gc("Boundary reset");
} }
} }

@ -411,9 +411,9 @@ class Core {
break; break;
case EntityOperation.SYNC: case EntityOperation.SYNC:
Helper.gc(); Helper.gc("Sync start");
onSynchronizeMessages(context, jargs, account, folder, (POP3Folder) ifolder, (POP3Store) istore, state); onSynchronizeMessages(context, jargs, account, folder, (POP3Folder) ifolder, (POP3Store) istore, state);
Helper.gc(); Helper.gc("Sync end");
break; break;
case EntityOperation.PURGE: case EntityOperation.PURGE:
@ -501,9 +501,9 @@ class Core {
break; break;
case EntityOperation.SYNC: case EntityOperation.SYNC:
Helper.gc(); Helper.gc("Sync start");
onSynchronizeMessages(context, jargs, account, folder, (IMAPStore) istore, (IMAPFolder) ifolder, state); onSynchronizeMessages(context, jargs, account, folder, (IMAPStore) istore, (IMAPFolder) ifolder, state);
Helper.gc(); Helper.gc("Sync end");
break; break;
case EntityOperation.SUBSCRIBE: case EntityOperation.SUBSCRIBE:

@ -1697,7 +1697,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
btnGC.setOnClickListener(new View.OnClickListener() { btnGC.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Helper.gc(true); Helper.gc("Miscellaneous");
DB.shrinkMemory(v.getContext()); DB.shrinkMemory(v.getContext());
} }
}); });

@ -3536,18 +3536,12 @@ public class Helper {
// Miscellaneous // Miscellaneous
static void gc() { static void gc(String reason) {
gc(false); try {
} Log.i("GC " + reason);
static void gc(boolean force) {
if (force || BuildConfig.DEBUG) {
Runtime.getRuntime().gc(); Runtime.getRuntime().gc();
try { } catch (Throwable ex) {
Thread.sleep(50); Log.e(ex);
} catch (InterruptedException ex) {
Log.e(ex);
}
} }
} }

Loading…
Cancel
Save