diff options
author | Brad Fitzpatrick <bradfitz@android.com> | 2010-07-27 18:34:08 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-07-27 18:34:08 -0700 |
commit | b73045935cd8ec5d1a1c5e7a7ca800448b5789ea (patch) | |
tree | 374ad5b9ff406fc285e7d60f5c1436f4a0fd9c00 /services | |
parent | 9b8e5566f99c55222db4127719440272f63a5361 (diff) | |
parent | e73eb531259126728e1d6e6b71ca65da28aaf0e0 (diff) | |
download | frameworks_base-b73045935cd8ec5d1a1c5e7a7ca800448b5789ea.zip frameworks_base-b73045935cd8ec5d1a1c5e7a7ca800448b5789ea.tar.gz frameworks_base-b73045935cd8ec5d1a1c5e7a7ca800448b5789ea.tar.bz2 |
Merge "Cap the size of StrictMode buffering we do before calling DropBox." into gingerbread
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/am/ActivityManagerService.java | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index c605b38..bcbda3e 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -6170,7 +6170,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen if (dbox == null || !dbox.isTagEnabled(dropboxTag)) return; boolean bufferWasEmpty; - + boolean needsFlush; final StringBuilder sb = isSystemApp ? mStrictModeBuffer : new StringBuilder(1024); synchronized (sb) { bufferWasEmpty = sb.length() == 0; @@ -6185,18 +6185,32 @@ public final class ActivityManagerService extends ActivityManagerNative implemen sb.append(crashInfo.stackTrace); } sb.append("\n"); + + // Only buffer up to ~64k. Various logging bits truncate + // things at 128k. + needsFlush = (sb.length() > 64 * 1024); } - // Non-system apps are isolated with a different tag & policy. - // They're also not batched. Batching is useful during system - // boot with strict system-wide logging policies and lots of - // things firing, but not common with regular apps, which - // won't ship with StrictMode dropboxing enabled. - if (!isSystemApp) { + // Flush immediately if the buffer's grown too large, or this + // is a non-system app. Non-system apps are isolated with a + // different tag & policy and not batched. + // + // Batching is useful during internal testing with + // StrictMode settings turned up high. Without batching, + // thousands of separate files could be created on boot. + if (!isSystemApp || needsFlush) { new Thread("Error dump: " + dropboxTag) { @Override public void run() { - dbox.addText(dropboxTag, sb.toString()); + String report; + synchronized (sb) { + report = sb.toString(); + sb.delete(0, sb.length()); + sb.trimToSize(); + } + if (report.length() != 0) { + dbox.addText(dropboxTag, report); + } } }.start(); return; @@ -6204,8 +6218,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // System app batching: if (!bufferWasEmpty) { - // An existing dropbox-writing thread is outstanding and - // will handle it. + // An existing dropbox-writing thread is outstanding, so + // we don't need to start it up. The existing thread will + // catch the buffer appends we just did. return; } |