1 description( 2 "This test checks whether the GC collects after string appends." 3 ); 4 5 // FIXME: This test appears to be highly tied to the details of how JS strings report memory 6 // cost to the garbage collector. It should be improved to be less tied to these implementation details. 7 // <https://bugs.webkit.org/show_bug.cgi?id=20871> 8 9 if (window.layoutTestController) 10 layoutTestController.dumpAsText(); 11 12 if (window.GCController) 13 GCController.collect(); 14 15 16 // str has 150 chars in it (which is greater than the limit of the GC to ignore which I believe is at 128). 17 var str = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; 18 var count = 500; 19 for (var i = 0; i < count; ++i) { 20 str += "b"; 21 } 22 23 // str has 128 chars in it. 24 str = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; 25 count = 10; 26 for (var i = 0; i < count; ++i) { 27 str += str; 28 } 29 30 var jsObjCount = 0; 31 if (window.GCController) 32 jsObjCount = GCController.getJSObjectCount(); 33 34 if (jsObjCount <= 500 && jsObjCount > 0) 35 testPassed("Garbage Collector triggered") 36 else 37 testFailed("Garbage Collector NOT triggered. Number of JSObjects: " + jsObjCount); 38 39 var successfullyParsed = true; 40