Commit 5f6251d1 authored by Stefano Facchini's avatar Stefano Facchini Committed by Robert Roth

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
parent 5b836afa
......@@ -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);
......
......@@ -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);
......
......@@ -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_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment