summaryrefslogtreecommitdiff
path: root/wikipedia
diff options
context:
space:
mode:
authorMatt Watson <mattdangerw@gmail.com>2014-01-22 15:36:39 -0800
committerMatt Watson <mattdangerw@gmail.com>2014-01-23 11:34:24 -0800
commit420acb55775e53708550995a4440b06b740d9308 (patch)
treed55bb0e395dc1506d42fc614c599a7e3c6c9229f /wikipedia
parentba9f365abe9cdd922e97bb85c181f33fb04a654c (diff)
Manually call System.gc() to limit memory usage
Wiki apps allocate pixbufs each time they draws at a new size. Memory will skyrocket unless will demand spidermonkey does some garbage collection
Diffstat (limited to 'wikipedia')
-rw-r--r--wikipedia/views/domain_wiki_view.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/wikipedia/views/domain_wiki_view.js b/wikipedia/views/domain_wiki_view.js
index a1de76e..7483767 100644
--- a/wikipedia/views/domain_wiki_view.js
+++ b/wikipedia/views/domain_wiki_view.js
@@ -1,7 +1,10 @@
const EndlessWikipedia = imports.wikipedia.EndlessWikipedia;
const Lang = imports.lang;
+const System = imports.system;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
+const Gdk = imports.gi.Gdk;
+const GLib = imports.gi.GLib;
const Endless = imports.gi.Endless;
const BackButton = imports.wikipedia.widgets.BackButton;
@@ -54,6 +57,16 @@ const DomainWikiView = new Lang.Class({
})
this._window.show_all();
+
+ // A temporary measure to prevent memory usage from blowing up. The app
+ // will sometimes allocate pixbufs as part of its draw function and gjs
+ // will not cleanup unused pixbufs unless we force it to.
+ this._window.connect_after("draw", function () {
+ Gdk.threads_add_idle(GLib.PRIORITY_LOW, function () {
+ System.gc();
+ return false;
+ });
+ });
},
create_front_page: function(){