Skip to content
Browse files

Make memory checking optional.

  • Loading branch information...
1 parent 50e5e66 commit 4111415913999cf67decdc8233a5eaf69df92e62 @Mossop committed Apr 22, 2013
Showing with 28 additions and 27 deletions.
  1. +1 −0 app-extension/bootstrap.js
  2. +20 −26 lib/sdk/test/harness.js
  3. +7 −1 python-lib/cuddlefish/__init__.py
View
1 app-extension/bootstrap.js
@@ -235,6 +235,7 @@ function startup(data, reasonCode) {
stopOnError: options.stopOnError,
verbose: options.verbose,
parseable: options.parseable,
+ checkMemory: options.check_memory,
}
}
});
View
46 lib/sdk/test/harness.js
@@ -165,35 +165,29 @@ function reportMemoryUsage() {
var gWeakrefInfo;
-function showLeaks() {
- let iterations = 0;
-
- function checkLeaks() {
- let leaks = getPotentialLeaks();
- let compartmentURLs = Object.keys(leaks.compartments).filter(function(url) {
- return !(url in startLeaks.compartments);
- });
-
- let windowURLs = Object.keys(leaks.windows).filter(function(url) {
- return !(url in startLeaks.windows);
- });
-
- if ((iterations < 10) && (compartmentURLs.length || windowURLs.length)) {
- iterations++;
- setTimeout(checkLeaks, 100);
- return;
- }
+function checkMemory() {
+ memory.gc();
+ setTimeout(function () {
+ memory.gc();
+ setTimeout(function () {
+ let leaks = getPotentialLeaks();
+ let compartmentURLs = Object.keys(leaks.compartments).filter(function(url) {
+ return !(url in startLeaks.compartments);
+ });
- for (let url of compartmentURLs)
- console.warn("LEAKED", leaks.compartments[url]);
+ let windowURLs = Object.keys(leaks.windows).filter(function(url) {
+ return !(url in startLeaks.windows);
+ });
- for (let url of windowURLs)
- console.warn("LEAKED", leaks.windows[url]);
+ for (let url of compartmentURLs)
+ console.warn("LEAKED", leaks.compartments[url]);
- showResults();
- }
+ for (let url of windowURLs)
+ console.warn("LEAKED", leaks.windows[url]);
- checkLeaks();
+ showResults();
+ });
+ });
}
function showResults() {
@@ -259,7 +253,7 @@ function cleanup() {
console.exception(e);
};
- setTimeout(showLeaks, 1);
+ setTimeout(require('@test/options').checkMemory ? checkMemory : showResults, 1);
// dump the coverobject
if (Object.keys(coverObject).length){
View
8 python-lib/cuddlefish/__init__.py
@@ -228,6 +228,12 @@
metavar=None,
default=False,
cmds=['sdocs'])),
+ (("", "--check-memory",), dict(dest="check_memory",
+ help="attempts to detect leaked compartments after a test run",
+ action="store_true",
+ default=False,
+ cmds=['test', 'testpkgs', 'testaddons',
+ 'testall'])),
]
),
@@ -660,7 +666,7 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
# a Mozilla application (which includes running tests).
use_main = False
- inherited_options = ['verbose', 'enable_e10s', 'parseable']
+ inherited_options = ['verbose', 'enable_e10s', 'parseable', 'check_memory']
enforce_timeouts = False
if command == "xpi":

0 comments on commit 4111415

Please sign in to comment.
Something went wrong with that request. Please try again.