[gnome-system-monitor] Use a different definition of Memory



commit 5f6251d1c31bc435a0b28b2a2be3a21b67876442
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Wed Jul 31 14:49:46 2013 +0200

    Use a different definition of Memory
    
    Currently, the "Memory" column is using the writable memory when
    available. While being a very good heuristics for identifying private
    process memory, it's damn slow to compute as it requires the whole
    memory map of the process. This is the single major culprit of the
    long-standing high CPU usage problem of the Process list in System Monitor.
    
    A much faster-to-compute approximation of private memory is the
    Resident Set Size (RSS), after subtracting the shared memory. While being
    an underestimation, it's still the best definition, roughly corresponding to
    the memory which would be freed by killing the process. This is the same value
    used by other popular system monitoring tools, like KSysGuard.
    
    This commit changes the definition of the Memory column from "writable" to
    "RSS - shared". Writable memory is no longer computed for every single
    process at every update of the list. Instead, it is just shown in the
    property dialog of the process.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=524830

 src/procproperties.cpp |    2 ++
 src/proctable.cpp      |   16 +++++++---------
 src/proctable.h        |    2 ++
 3 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/src/procproperties.cpp b/src/procproperties.cpp
index 302ca56..238b922 100644
--- a/src/procproperties.cpp
+++ b/src/procproperties.cpp
@@ -67,6 +67,8 @@ fill_proc_properties (GtkWidget *tree, ProcInfo *info)
     if (!info)
         return;
 
+    get_process_memory_writable (info);
+
 #if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
     struct clockinfo cinf;
     size_t size = sizeof (cinf);
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 8fa9741..1ba0b18 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -460,6 +460,10 @@ proctable_new (ProcmanApp * const app)
           continue;
         }
 #endif
+
+        if (i == COL_MEMWRITABLE)
+            continue;
+
         cell = gtk_cell_renderer_text_new();
         col = gtk_tree_view_column_new();
         gtk_tree_view_column_pack_start(col, cell, TRUE);
@@ -484,7 +488,6 @@ proctable_new (ProcmanApp * const app)
             case COL_MEMRES:
             case COL_MEMSHARED:
             case COL_MEM:
-            case COL_MEMWRITABLE:
                 gtk_tree_view_column_set_cell_data_func(col, cell,
                                                         &procman::size_na_cell_data_func,
                                                         GUINT_TO_POINTER(i),
@@ -531,7 +534,6 @@ proctable_new (ProcmanApp * const app)
             case COL_MEMRES:
             case COL_MEMSHARED:
             case COL_MEM:
-            case COL_MEMWRITABLE:
             case COL_CPU:
             case COL_CPU_TIME:
             case COL_START_TIME:
@@ -553,7 +555,6 @@ proctable_new (ProcmanApp * const app)
         {
             case COL_VMSIZE:
             case COL_MEMRES:
-            case COL_MEMWRITABLE:
             case COL_MEMSHARED:
 #ifdef HAVE_WNCK
             case COL_MEMXSERVER:
@@ -712,7 +713,8 @@ ProcInfo::set_user(guint uid)
     this->user = lookup_user(uid);
 }
 
-static void get_process_memory_writable(ProcInfo *info)
+void
+get_process_memory_writable (ProcInfo *info)
 {
     glibtop_proc_map buf;
     glibtop_map_entry *maps;
@@ -756,10 +758,7 @@ get_process_memory_info(ProcInfo *info)
     info->memres    = procmem.resident;
     info->memshared = procmem.share;
 
-    get_process_memory_writable(info);
-
-    // fake the smart memory column if writable is not available
-    info->mem = info->memwritable ? info->memwritable : info->memres;
+    info->mem = info->memres - info->memshared;
 #ifdef HAVE_WNCK
     info->mem += info->memxserver;
 #endif
@@ -781,7 +780,6 @@ update_info_mutable_cols(ProcInfo *info)
     tree_store_update(model, &info->node, COL_USER, info->user.c_str());
     tree_store_update(model, &info->node, COL_VMSIZE, info->vmsize);
     tree_store_update(model, &info->node, COL_MEMRES, info->memres);
-    tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable);
     tree_store_update(model, &info->node, COL_MEMSHARED, info->memshared);
 #ifdef HAVE_WNCK
     tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver);
diff --git a/src/proctable.h b/src/proctable.h
index d7a7d35..f7cb46a 100644
--- a/src/proctable.h
+++ b/src/proctable.h
@@ -72,4 +72,6 @@ void            proctable_set_columns_order(GtkTreeView *treeview, GSList *order
 
 char*           make_loadavg_string(void);
 
+void            get_process_memory_writable (ProcInfo *info);
+
 #endif /* _PROCMAN_PROCTABLE_H_ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]