michael@0: // |reftest| skip-if(!xulRuntime.shell) slow michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 319980; michael@0: var summary = 'GC not called during non-fatal out of memory'; michael@0: var actual = ''; michael@0: var expect = 'Normal Exit'; michael@0: michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: print ('This test should never fail explicitly. ' + michael@0: 'You must view the memory usage during the test. ' + michael@0: 'This test fails if memory usage for each subtest grows'); michael@0: michael@0: var timeOut = 45 * 1000; michael@0: var interval = 0.01 * 1000; michael@0: var testFuncWatcherId; michael@0: var testFuncTimerId; michael@0: var maxTests = 5; michael@0: var currTest = 0; michael@0: michael@0: if (typeof setTimeout == 'undefined') michael@0: { michael@0: setTimeout = function() {}; michael@0: clearTimeout = function() {}; michael@0: actual = 'Normal Exit'; michael@0: reportCompare(expect, actual, summary); michael@0: } michael@0: else michael@0: { michael@0: // delay start until after js-test-driver-end runs. michael@0: // delay test driver end michael@0: gDelayTestDriverEnd = true; michael@0: michael@0: setTimeout(testFuncWatcher, 1000); michael@0: } michael@0: michael@0: function testFuncWatcher() michael@0: { michael@0: a = null; michael@0: michael@0: gc(); michael@0: michael@0: clearTimeout(testFuncTimerId); michael@0: testFuncWatcherId = testFuncTimerId = null; michael@0: if (currTest >= maxTests) michael@0: { michael@0: actual = 'Normal Exit'; michael@0: reportCompare(expect, actual, summary); michael@0: printStatus('Test Completed'); michael@0: gDelayTestDriverEnd = false; michael@0: jsTestDriverEnd(); michael@0: return; michael@0: } michael@0: ++currTest; michael@0: michael@0: print('Executing test ' + currTest + '\n'); michael@0: michael@0: testFuncWatcherId = setTimeout("testFuncWatcher()", timeOut); michael@0: testFuncTimerId = setTimeout(testFunc, interval); michael@0: } michael@0: michael@0: michael@0: var a; michael@0: function testFunc() michael@0: { michael@0: michael@0: var i; michael@0: michael@0: switch(currTest) michael@0: { michael@0: case 1: michael@0: a = new Array(100000); michael@0: for (i = 0; i < 100000; i++ ) michael@0: { michael@0: a[i] = i; michael@0: } michael@0: break; michael@0: michael@0: case 2: michael@0: a = new Array(100000); michael@0: for (i = 0; i < 100000; i++) michael@0: { michael@0: a[i] = new Number(); michael@0: a[i] = i; michael@0: } michael@0: break; michael@0: michael@0: case 3: michael@0: a = new String() ; michael@0: a = new Array(100000); michael@0: for ( i = 0; i < 100000; i++ ) michael@0: { michael@0: a[i] = i; michael@0: } michael@0: michael@0: break; michael@0: michael@0: case 4: michael@0: a = new Array(); michael@0: a[0] = new Array(100000); michael@0: for (i = 0; i < 100000; i++ ) michael@0: { michael@0: a[0][i] = i; michael@0: } michael@0: break; michael@0: michael@0: case 5: michael@0: a = new Array(); michael@0: for (i = 0; i < 100000; i++ ) michael@0: { michael@0: a[i] = i; michael@0: } michael@0: break; michael@0: } michael@0: michael@0: if (testFuncTimerId) michael@0: { michael@0: testFuncTimerId = setTimeout(testFunc, interval); michael@0: } michael@0: } michael@0: michael@0: