diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index d11b129..a5844a3 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -16,7 +16,6 @@
 
 #include <ctype.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 #include <sys/user.h>
 #include <time.h>
@@ -281,15 +280,14 @@
         size_t second_worst_sizes = 0;
 
         if ((id != LOG_ID_CRASH) && mPrune.worstUidEnabled()) {
-            const UidEntry **sorted = stats.sort(2, id);
+            std::unique_ptr<const UidEntry *[]> sorted = stats.sort(2, id);
 
-            if (sorted) {
+            if (sorted.get()) {
                 if (sorted[0] && sorted[1]) {
                     worst = sorted[0]->getKey();
                     worst_sizes = sorted[0]->getSizes();
                     second_worst_sizes = sorted[1]->getSizes();
                 }
-                delete [] sorted;
             }
         }
 
diff --git a/logd/LogStatistics.cpp b/logd/LogStatistics.cpp
index accd660..6e5454a 100644
--- a/logd/LogStatistics.cpp
+++ b/logd/LogStatistics.cpp
@@ -17,7 +17,6 @@
 #include <algorithm> // std::max
 #include <fcntl.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
@@ -27,7 +26,8 @@
 
 #include "LogStatistics.h"
 
-LogStatistics::LogStatistics() {
+LogStatistics::LogStatistics()
+        : enable(false) {
     log_id_for_each(id) {
         mSizes[id] = 0;
         mElements[id] = 0;
@@ -36,8 +36,10 @@
     }
 }
 
+namespace android {
+
 // caller must own and free character string
-char *LogStatistics::pidToName(pid_t pid) {
+static char *pidToName(pid_t pid) {
     char *retval = NULL;
     if (pid == 0) { // special case from auditd for kernel
         retval = strdup("logd.auditd");
@@ -60,6 +62,8 @@
     return retval;
 }
 
+}
+
 void LogStatistics::add(LogBufferElement *e) {
     log_id_t log_id = e->getLogId();
     unsigned short size = e->getMsgLen();
@@ -81,6 +85,31 @@
 
     mSizesTotal[log_id] += size;
     ++mElementsTotal[log_id];
+
+    if (!enable) {
+        return;
+    }
+
+    pid_t pid = e->getPid();
+    hash = android::hash_type(pid);
+    index = pidTable.find(-1, hash, pid);
+    if (index == -1) {
+        PidEntry initEntry(pid, uid, android::pidToName(pid));
+        initEntry.add(size);
+        pidTable.add(hash, initEntry);
+    } else {
+        PidEntry &entry = pidTable.editEntryAt(index);
+        if (entry.getUid() != uid) {
+            entry.setUid(uid);
+            entry.setName(android::pidToName(pid));
+        } else if (!entry.getName()) {
+            char *name = android::pidToName(pid);
+            if (name) {
+                entry.setName(name);
+            }
+        }
+        entry.add(size);
+    }
 }
 
 void LogStatistics::subtract(LogBufferElement *e) {
@@ -99,33 +128,20 @@
             table.removeAt(index);
         }
     }
-}
 
-// caller must own and delete UidEntry array
-const UidEntry **LogStatistics::sort(size_t n, log_id id) {
-    if (!n) {
-        return NULL;
+    if (!enable) {
+        return;
     }
 
-    const UidEntry **retval = new const UidEntry* [n];
-    memset(retval, 0, sizeof(*retval) * n);
-
-    uidTable_t &table = uidTable[id];
-    ssize_t index = -1;
-    while ((index = table.next(index)) >= 0) {
-        const UidEntry &entry = table.entryAt(index);
-        size_t s = entry.getSizes();
-        ssize_t i = n - 1;
-        while ((!retval[i] || (s > retval[i]->getSizes())) && (--i >= 0));
-        if (++i < (ssize_t)n) {
-            size_t b = n - i - 1;
-            if (b) {
-                memmove(&retval[i+1], &retval[i], b * sizeof(retval[0]));
-            }
-            retval[i] = &entry;
+    pid_t pid = e->getPid();
+    hash = android::hash_type(pid);
+    index = pidTable.find(-1, hash, pid);
+    if (index != -1) {
+        PidEntry &entry = pidTable.editEntryAt(index);
+        if (entry.subtract(size)) {
+            pidTable.removeAt(index);
         }
     }
-    return retval;
 }
 
 // caller must own and free character string
@@ -145,8 +161,29 @@
         ++info;
     }
 
+    char *name = NULL;
+
+    // report uid -> pid(s) -> pidToName if unique
+    ssize_t index = -1;
+    while ((index = pidTable.next(index)) != -1) {
+        const PidEntry &entry = pidTable.entryAt(index);
+
+        if (entry.getUid() == uid) {
+            const char *n = entry.getName();
+
+            if (n) {
+                if (!name) {
+                    name = strdup(n);
+                } else if (strcmp(name, n)) {
+                    free(name);
+                    return NULL;
+                }
+            }
+        }
+    }
+
     // No one
-    return NULL;
+    return name;
 }
 
 static void format_line(android::String8 &output,
@@ -223,37 +260,23 @@
     // Report on Chattiest
 
     // Chattiest by application (UID)
+    static const size_t maximum_sorted_entries = 32;
     log_id_for_each(id) {
         if (!(logMask & (1 << id))) {
             continue;
         }
 
-        static const size_t maximum_sorted_entries = 32;
-        const UidEntry **sorted = sort(maximum_sorted_entries, id);
-
-        if (!sorted) {
-            continue;
-        }
-
-        bool print = false;
-        for(size_t index = 0; index < maximum_sorted_entries; ++index) {
+        bool headerPrinted = false;
+        std::unique_ptr<const UidEntry *[]> sorted = sort(maximum_sorted_entries, id);
+        ssize_t index = -1;
+        while ((index = uidTable_t::next(index, sorted, maximum_sorted_entries)) >= 0) {
             const UidEntry *entry = sorted[index];
-
-            if (!entry) {
-                break;
-            }
-
-            size_t sizes = entry->getSizes();
-            if (sizes < (65536/100)) {
-                break;
-            }
-
             uid_t u = entry->getKey();
             if ((uid != AID_ROOT) && (u != uid)) {
                 continue;
             }
 
-            if (!print) {
+            if (!headerPrinted) {
                 if (uid == AID_ROOT) {
                     output.appendFormat(
                         "\n\nChattiest UIDs in %s:\n",
@@ -266,7 +289,7 @@
                         "\n\nLogging for your UID in %s:\n",
                         android_log_id_to_name(id));
                 }
-                print = true;
+                headerPrinted = true;
             }
 
             android::String8 name("");
@@ -278,18 +301,62 @@
             }
 
             android::String8 size("");
-            size.appendFormat("%zu", sizes);
+            size.appendFormat("%zu", entry->getSizes());
 
             format_line(output, name, size);
         }
+    }
 
-        delete [] sorted;
+    if (enable) {
+        bool headerPrinted = false;
+        std::unique_ptr<const PidEntry *[]> sorted = pidTable.sort(maximum_sorted_entries);
+        ssize_t index = -1;
+        while ((index = pidTable.next(index, sorted, maximum_sorted_entries)) >= 0) {
+            const PidEntry *entry = sorted[index];
+            uid_t u = entry->getUid();
+            if ((uid != AID_ROOT) && (u != uid)) {
+                continue;
+            }
+
+            if (!headerPrinted) {
+                if (uid == AID_ROOT) {
+                    output.appendFormat("\n\nChattiest PIDs:\n");
+                } else {
+                    output.appendFormat("\n\nLogging for this PID:\n");
+                }
+                android::String8 name("  PID/UID");
+                android::String8 size("Size");
+                android::String8 pruned("Pruned");
+                format_line(output, name, size, pruned);
+                headerPrinted = true;
+            }
+
+            android::String8 name("");
+            name.appendFormat("%5u/%u", entry->getKey(), u);
+            const char *n = entry->getName();
+            if (n) {
+                name.appendFormat("%*s%s", (int)std::max(12 - name.length(), (size_t)1), "", n);
+            } else {
+                char *un = uidToName(u);
+                if (un) {
+                    name.appendFormat("%*s%s", (int)std::max(12 - name.length(), (size_t)1), "", un);
+                    free(un);
+                }
+            }
+
+            android::String8 size("");
+            size.appendFormat("%zu", entry->getSizes());
+
+            format_line(output, name, size);
+        }
     }
 
     *buf = strdup(output.string());
 }
 
-uid_t LogStatistics::pidToUid(pid_t pid) {
+namespace android {
+
+uid_t pidToUid(pid_t pid) {
     char buffer[512];
     snprintf(buffer, sizeof(buffer), "/proc/%u/status", pid);
     FILE *fp = fopen(buffer, "r");
@@ -305,3 +372,52 @@
     }
     return getuid(); // associate this with the logger
 }
+
+}
+
+uid_t LogStatistics::pidToUid(pid_t pid) {
+    uid_t uid;
+    android::hash_t hash = android::hash_type(pid);
+    ssize_t index = pidTable.find(-1, hash, pid);
+    if (index == -1) {
+        uid = android::pidToUid(pid);
+        PidEntry initEntry(pid, uid, android::pidToName(pid));
+        pidTable.add(hash, initEntry);
+    } else {
+        PidEntry &entry = pidTable.editEntryAt(index);
+        if (!entry.getName()) {
+            char *name = android::pidToName(pid);
+            if (name) {
+                entry.setName(name);
+            }
+        }
+        uid = entry.getUid();
+    }
+    return uid;
+}
+
+// caller must free character string
+char *LogStatistics::pidToName(pid_t pid) {
+    char *name;
+
+    android::hash_t hash = android::hash_type(pid);
+    ssize_t index = pidTable.find(-1, hash, pid);
+    if (index == -1) {
+        name = android::pidToName(pid);
+        PidEntry initEntry(pid, android::pidToUid(pid), name ? strdup(name) : NULL);
+        pidTable.add(hash, initEntry);
+    } else {
+        PidEntry &entry = pidTable.editEntryAt(index);
+        const char *n = entry.getName();
+        if (n) {
+            name = strdup(n);
+        } else {
+            name = android::pidToName(pid);
+            if (name) {
+                entry.setName(strdup(name));
+            }
+        }
+    }
+
+    return name;
+}
diff --git a/logd/LogStatistics.h b/logd/LogStatistics.h
index d5b8762..a65ffe0 100644
--- a/logd/LogStatistics.h
+++ b/logd/LogStatistics.h
@@ -17,6 +17,8 @@
 #ifndef _LOGD_LOG_STATISTICS_H__
 #define _LOGD_LOG_STATISTICS_H__
 
+#include <memory>
+#include <stdlib.h>
 #include <sys/types.h>
 
 #include <log/log.h>
@@ -27,6 +29,52 @@
 #define log_id_for_each(i) \
     for (log_id_t i = LOG_ID_MIN; i < LOG_ID_MAX; i = (log_id_t) (i + 1))
 
+template <typename TKey, typename TEntry>
+class LogHashtable : public android::BasicHashtable<TKey, TEntry> {
+public:
+    std::unique_ptr<const TEntry *[]> sort(size_t n) {
+        if (!n) {
+            std::unique_ptr<const TEntry *[]> sorted(NULL);
+            return sorted;
+        }
+
+        const TEntry **retval = new const TEntry* [n];
+        memset(retval, 0, sizeof(*retval) * n);
+
+        ssize_t index = -1;
+        while ((index = android::BasicHashtable<TKey, TEntry>::next(index)) >= 0) {
+            const TEntry &entry = android::BasicHashtable<TKey, TEntry>::entryAt(index);
+            size_t s = entry.getSizes();
+            ssize_t i = n - 1;
+            while ((!retval[i] || (s > retval[i]->getSizes())) && (--i >= 0))
+                ;
+            if (++i < (ssize_t)n) {
+                size_t b = n - i - 1;
+                if (b) {
+                    memmove(&retval[i+1], &retval[i], b * sizeof(retval[0]));
+                }
+                retval[i] = &entry;
+            }
+        }
+        std::unique_ptr<const TEntry *[]> sorted(retval);
+        return sorted;
+    }
+
+    // Iteration handler for the sort method output
+    static ssize_t next(ssize_t index, std::unique_ptr<const TEntry *[]> &sorted, size_t n) {
+        ++index;
+        if (!sorted.get() || (index < 0) || (n <= (size_t)index) || !sorted[index]
+         || (sorted[index]->getSizes() <= (sorted[0]->getSizes() / 100))) {
+            return -1;
+        }
+        return index;
+    }
+
+    ssize_t next(ssize_t index) {
+        return android::BasicHashtable<TKey, TEntry>::next(index);
+    }
+};
+
 struct UidEntry {
     const uid_t uid;
     size_t size;
@@ -39,27 +87,55 @@
     inline bool subtract(size_t s) { size -= s; return !size; }
 };
 
+struct PidEntry {
+    const pid_t pid;
+    uid_t uid;
+    char *name;
+    size_t size;
+
+    PidEntry(pid_t p, uid_t u, char *n):pid(p),uid(u),name(n),size(0) { }
+    PidEntry(const PidEntry &c):
+        pid(c.pid),
+        uid(c.uid),
+        name(c.name ? strdup(c.name) : NULL),
+        size(c.size) { }
+    ~PidEntry() { free(name); }
+
+    const pid_t&getKey() const { return pid; }
+    const uid_t&getUid() const { return uid; }
+    uid_t&setUid(uid_t u) { return uid = u; }
+    const char*getName() const { return name; }
+    char *setName(char *n) { free(name); return name = n; }
+    size_t getSizes() const { return size; }
+    inline void add(size_t s) { size += s; }
+    inline bool subtract(size_t s) { size -= s; return !size; }
+};
+
 // Log Statistics
 class LogStatistics {
     size_t mSizes[LOG_ID_MAX];
     size_t mElements[LOG_ID_MAX];
     size_t mSizesTotal[LOG_ID_MAX];
     size_t mElementsTotal[LOG_ID_MAX];
+    bool enable;
 
     // uid to size list
-    typedef android::BasicHashtable<uid_t, UidEntry> uidTable_t;
+    typedef LogHashtable<uid_t, UidEntry> uidTable_t;
     uidTable_t uidTable[LOG_ID_MAX];
 
+    // pid to uid list
+    typedef LogHashtable<pid_t, PidEntry> pidTable_t;
+    pidTable_t pidTable;
+
 public:
     LogStatistics();
 
-    void enableStatistics() { }
+    void enableStatistics() { enable = true; }
 
     void add(LogBufferElement *entry);
     void subtract(LogBufferElement *entry);
 
-    // Caller must delete array
-    const UidEntry **sort(size_t n, log_id i);
+    std::unique_ptr<const UidEntry *[]> sort(size_t n, log_id i) { return uidTable[i].sort(n); }
 
     // fast track current value by id only
     size_t sizes(log_id_t id) const { return mSizes[id]; }
