Skip to content

Commit

Permalink
button to perform garbage collection cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyrne01 committed Feb 23, 2015
1 parent 6943a20 commit 62f2f78
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 83 deletions.
36 changes: 28 additions & 8 deletions addon/data/html/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@
<body>

<div class="tabs">

<div class="tab">
<input type="radio" id="tab-1" name="tab-group-1" hidden checked />
<label class="tabLabel" for="tab-1">Counts</label>
<label class="tabLabel" for="tab-1">Memory usage</label>
<div class="content">
<div id="memoryDump"></div>
</div>
</div>

<div class="tab">
<input type="radio" id="tab-2" name="tab-group-1" hidden />
<label class="tabLabel" for="tab-2">Counts</label>
<div class="content">
<table>
<tr>
Expand Down Expand Up @@ -42,13 +51,7 @@
</table>
</div>
</div>
<div class="tab">
<input type="radio" id="tab-2" name="tab-group-1" hidden />
<label class="tabLabel" for="tab-2">Memory usage</label>
<div class="content">
<div id="memoryDump"></div>
</div>
</div>

<div class="tab">
<input type="radio" id="tab-3" name="tab-group-1" hidden />
<label class="tabLabel" for="tab-3">Settings</label>
Expand Down Expand Up @@ -96,6 +99,23 @@
<input id="memoryCautionColorPref" type="text" />
</td>
</tr>-->
<tr>
<td>
<label>Perform a garbage collection</label>
</td>
<td>
<button id="schedulePreciseGC">Run</button>
<label id="schedulePreciseGCStatus"></label>
</td>
</tr>
<!-- <tr>
<td>
<label>Force a garbage collection followed by a cycle collection</label>
</td>
<td>
<button id="garbageCollect">Perform GC and CC</button>
</td>
</tr>-->
</table>
</div>
</div>
Expand Down
17 changes: 17 additions & 0 deletions addon/data/js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ document.getElementById('memoryCautionColorPref').onkeyup = function (event) {
self.port.emit("memoryCautionColorPrefSetting", document.getElementById('memoryCautionColorPref').value);
};*/

document.getElementById('schedulePreciseGC').addEventListener("click", function (event) {
document.getElementById('schedulePreciseGC').disabled = true;
self.port.emit("schedulePreciseGC", '');
}, false);

/*document.getElementById('garbageCollect').addEventListener("click", function (event) {
self.port.emit("garbageCollect", '');
}, false);*/



/*
Expand Down Expand Up @@ -87,3 +96,11 @@ self.port.on("memoryDump", function (value) {
document.getElementById("memoryDump").appendChild(document.createElement('br'));
}
});

self.port.on("schedulePreciseGC", function (value) {
document.getElementById('schedulePreciseGCStatus').textContent = value;
document.getElementById('schedulePreciseGC').disabled = false;
setTimeout(function(){
document.getElementById('schedulePreciseGCStatus').textContent = '';
}, 5000);
});
23 changes: 19 additions & 4 deletions addon/lib/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ var Panel = require("sdk/panel"),
Button = require("./ToggleButton"),
Preference = require("./Preference"),
panel;
const {
Ci, Cc, Cu
} = require("chrome");

exports.init = function () {

Expand Down Expand Up @@ -36,8 +39,8 @@ exports.init = function () {

panel.port.on("memoryTrackingSetting", function (value) {
Preference.set('memoryTracking', value);
if (!Preference.get('memoryTracking')){

if (!Preference.get('memoryTracking')) {
Tab.removeScheduledFunction();
Tab.rollbackTitles();
}
Expand All @@ -51,8 +54,8 @@ exports.init = function () {

panel.port.on("memoryUsageOnTabTitlesSetting", function (value) {
Preference.set('memoryUsageOnTabTitles', value);
if (!Preference.get('memoryUsageOnTabTitles')){

if (!Preference.get('memoryUsageOnTabTitles')) {
Tab.rollbackTitles();
}
});
Expand All @@ -64,6 +67,18 @@ exports.init = function () {
panel.port.on("memoryCautionColorSetting", function (value) {
Preference.set('memoryCautionColor', value);
});

panel.port.on("schedulePreciseGC", function (value) {
Cu.schedulePreciseGC(
function () {
panel.port.emit('schedulePreciseGC', 'done');
}
);
});

panel.port.on("garbageCollect", function (value) {
// TODO implement
});
};

exports.get = function () {
Expand Down
4 changes: 2 additions & 2 deletions addon/lib/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function initFinishReporting() {
}

exports.rollbackTitles = function () {

for each(var tab in tabs) {

tab.title = (tab.title.indexOf('B: ') >= 0 ? tab.title.split('B: ')[1] : tab.title);
Expand All @@ -183,6 +183,6 @@ exports.removeScheduledFunction = function () {
};

exports.reinitTimeout = function () {

timeoutId = require("sdk/timers").setTimeout(updateMemoryCounters, Preference.get("memoryInterval") * 1000);
};
78 changes: 36 additions & 42 deletions addon/package.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,38 @@
{
"name": "tab-data-addon",
"title": "Tab Data",
"id": "jid1-4ogjq7MUzAiCOw",
"description": "Provides user with tab related stats/data",
"author": "Robert Byrne",
"license": "GNU GPL v3",
"version": "0.2.7",
"permissions": {
"private-browsing": true
},
"preferences": [
{
"name": "memoryInterval",
"title": "How many seconds between memory data collection?",
"type": "string",
"value": "10"
},
{
"name": "memoryTracking",
"title": "Enable memory usage tracking?",
"type": "bool",
"value": true
},
{
"name": "memoryUsageOnTabTitles",
"title": "Show memory usage in tab titles?",
"type": "bool",
"value": true
},
{
"name": "memoryCautionThreshold",
"title": "Memory caution threshold? (In megabytes)",
"type": "string",
"value": "50"
},
{
"name": "memoryCautionColor",
"title": "Color of tab title if threshold exceeded?",
"type": "string",
"value": "#FF5050"
}
]
"name": "tab-data-addon",
"title": "Tab Data",
"id": "jid1-4ogjq7MUzAiCOw",
"description": "Provides user with tab related stats/data",
"author": "Robert Byrne",
"license": "GNU GPL v3",
"version": "0.2.7",
"permissions": {
"private-browsing": true
},
"preferences": [{
"name": "memoryInterval",
"title": "How many seconds between memory data collection?",
"type": "string",
"value": "10"
}, {
"name": "memoryTracking",
"title": "Enable memory usage tracking?",
"type": "bool",
"value": true
}, {
"name": "memoryUsageOnTabTitles",
"title": "Show memory usage in tab titles?",
"type": "bool",
"value": true
}, {
"name": "memoryCautionThreshold",
"title": "Memory caution threshold? (In megabytes)",
"type": "string",
"value": "50"
}, {
"name": "memoryCautionColor",
"title": "Color of tab title if threshold exceeded?",
"type": "string",
"value": "#FF5050"
}]
}
54 changes: 27 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"name": "tab-data-firefox",
"version": "0.2.7",
"description": "Firefox addon providing user with tab related stats/data",
"main": "addon/lib/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/bobbyrne01/tab-data-firefox.git"
},
"author": "Robert Byrne",
"license": "GNU GPL v3",
"bugs": {
"url": "https://github.com/bobbyrne01/tab-data-firefox/issues"
},
"homepage": "https://github.com/bobbyrne01/tab-data-firefox",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-csslint": "^0.4.0",
"grunt-contrib-jshint": "^0.11.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-html-validation": "^0.1.18",
"grunt-jsbeautifier": "^0.2.7",
"grunt-notify": "^0.4.1",
"grunt-release": "^0.11.0"
}
"name": "tab-data-firefox",
"version": "0.2.7",
"description": "Firefox addon providing user with tab related stats/data",
"main": "addon/lib/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/bobbyrne01/tab-data-firefox.git"
},
"author": "Robert Byrne",
"license": "GNU GPL v3",
"bugs": {
"url": "https://github.com/bobbyrne01/tab-data-firefox/issues"
},
"homepage": "https://github.com/bobbyrne01/tab-data-firefox",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-csslint": "^0.4.0",
"grunt-contrib-jshint": "^0.11.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-html-validation": "^0.1.18",
"grunt-jsbeautifier": "^0.2.7",
"grunt-notify": "^0.4.1",
"grunt-release": "^0.11.0"
}
}

0 comments on commit 62f2f78

Please sign in to comment.