[gnome-shell] memory: Add display of elapsed seconds since a garbage collection
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] memory: Add display of elapsed seconds since a garbage collection
- Date: Sat, 17 Sep 2011 14:22:57 +0000 (UTC)
commit 36bfe8c533463640571fb8a4b517459320ffadde
Author: Colin Walters <walters verbum org>
Date: Thu Sep 15 19:36:07 2011 -0400
memory: Add display of elapsed seconds since a garbage collection
This is useful information for debugging.
https://bugzilla.gnome.org/show_bug.cgi?id=659254
js/ui/lookingGlass.js | 4 ++++
src/shell-global.c | 19 +++++++++++++++++++
src/shell-global.h | 3 +++
3 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index 939d2a2..c24f75b 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -607,6 +607,9 @@ Memory.prototype = {
this._gjs_closure = new St.Label();
this.actor.add(this._gjs_closure);
+ this._last_gc_seconds_ago = new St.Label();
+ this.actor.add(this._last_gc_seconds_ago);
+
this._gcbutton = new St.Button({ label: 'Full GC',
style_class: 'lg-obj-inspector-button' });
this._gcbutton.connect('clicked', Lang.bind(this, function () { global.gc(); this._renderText(); }));
@@ -626,6 +629,7 @@ Memory.prototype = {
this._gjs_gobject.text = 'gjs_gobject: ' + memInfo.gjs_gobject;
this._gjs_function.text = 'gjs_function: ' + memInfo.gjs_function;
this._gjs_closure.text = 'gjs_closure: ' + memInfo.gjs_closure;
+ this._last_gc_seconds_ago.text = 'last_gc_seconds_ago: ' + memInfo.last_gc_seconds_ago;
}
};
diff --git a/src/shell-global.c b/src/shell-global.c
index 3334b52..98b51be 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -42,6 +42,8 @@
static ShellGlobal *the_object = NULL;
static void grab_notify (GtkWidget *widget, gboolean is_grab, gpointer user_data);
+static void shell_global_on_gc (GjsContext *context,
+ ShellGlobal *global);
struct _ShellGlobal {
GObject parent;
@@ -87,6 +89,8 @@ struct _ShellGlobal {
ca_context *sound_context;
guint32 xdnd_timestamp;
+
+ gint64 last_gc_end_time;
};
enum {
@@ -270,7 +274,10 @@ shell_global_init (ShellGlobal *global)
global->js_context = g_object_new (GJS_TYPE_CONTEXT,
"search-path", search_path,
"js-version", "1.8",
+ "gc-notifications", TRUE,
NULL);
+ g_signal_connect (global->js_context, "gc", G_CALLBACK (shell_global_on_gc), global);
+
g_strfreev (search_path);
}
@@ -1149,6 +1156,13 @@ shell_global_maybe_gc (ShellGlobal *global)
gjs_context_maybe_gc (global->js_context);
}
+static void
+shell_global_on_gc (GjsContext *context,
+ ShellGlobal *global)
+{
+ global->last_gc_end_time = g_get_monotonic_time ();
+}
+
/**
* shell_global_get_memory_info:
* @global:
@@ -1161,6 +1175,7 @@ shell_global_get_memory_info (ShellGlobal *global,
ShellMemoryInfo *meminfo)
{
JSContext *context;
+ gint64 now;
memset (meminfo, 0, sizeof (meminfo));
#ifdef HAVE_MALLINFO
@@ -1178,6 +1193,10 @@ shell_global_get_memory_info (ShellGlobal *global,
meminfo->gjs_gobject = (unsigned int) gjs_counter_object.value;
meminfo->gjs_function = (unsigned int) gjs_counter_function.value;
meminfo->gjs_closure = (unsigned int) gjs_counter_closure.value;
+
+ now = g_get_monotonic_time ();
+
+ meminfo->last_gc_seconds_ago = (now - global->last_gc_end_time) / G_TIME_SPAN_SECOND;
}
diff --git a/src/shell-global.h b/src/shell-global.h
index 4018f5f..cc5cfe7 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -96,6 +96,9 @@ typedef struct {
guint gjs_gobject;
guint gjs_function;
guint gjs_closure;
+
+ /* 32 bit to avoid js conversion problems with 64 bit */
+ guint last_gc_seconds_ago;
} ShellMemoryInfo;
void shell_global_get_memory_info (ShellGlobal *global,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]