RESOLVED INVALID 140919
WeakMap Object key expected to be garbage collected is not
https://bugs.webkit.org/show_bug.cgi?id=140919
Summary WeakMap Object key expected to be garbage collected is not
Joseph Pecoraro
Reported 2015-01-26 19:21:34 PST
* SUMMARY In a LayoutTest I am adding to test WeakMap, an Object I expected to be garbage collected is not. This reproduces 100% for me in Debug (x84_64) builds, but does not in Release builds on the same machine. * STEPS TO REPRODUCE 1. shell> run-webkit-tests --debug LayoutTests/inspector/model/remote-object-weak-collection.html => FAILURE After these series of steps: > strongKey1 = {id:1}; > strongKey2 = {id:2}; > weakMap = new WeakMap; > > GCController.collect(); > weakMap.set(strongKey1, 1); > weakMap.set(strongKey2, 2); > GCController.collect(); > delete window.strongKey1; > GCController.collect(); > weakMap.set({id:3}, 3); > weakMap.set({id:4}, 4); > GCController.collect(); > weakMap I expect the temporary object {id:4} to be garbage collected, but it is not. * RESULTS DIFF --- Build/Debug/layout-test-results/inspector/model/remote-object-weak-collection-expected.txt +++ Build/Debug/layout-test-results/inspector/model/remote-object-weak-collection-actual.txt @@ -119,6 +119,31 @@ "value": 2, "description": "2" } + }, + { + "key": { + "type": "object", + "objectId": "<filtered>", + "className": "Object", + "description": "Object", + "preview": { + "type": "object", + "description": "Object", + "lossless": true, + "properties": [ + { + "name": "id", + "type": "number", + "value": "4" + } + ] + } + }, + "value": { + "type": "number", + "value": 4, + "description": "4" + } } ]
Attachments
Joseph Pecoraro
Comment 1 2015-01-26 19:22:20 PST
Even though the test reproduces in Debug builds, I have seen some objects that I expect to get released, not get released in Release builds. I just do not have a reliable way to reproduce that issue.
Radar WebKit Bug Importer
Comment 2 2015-01-26 19:22:53 PST
Joseph Pecoraro
Comment 3 2015-01-26 19:24:33 PST
The test and inspector pieces have not landed yet. It is currently up for review on bug 122867.
Joseph Pecoraro
Comment 4 2015-01-27 14:23:06 PST
Geoff and I debugged this for a bit, and it looks like this is okay. For one, eventually in the test the object does get cleaned up so long term that looks fine. But further investigation into why it was temporary alive, it looks like the object is alive because it is on the stack during collection. Adding a "timeout" between the map mutation and collection, the object goes away as expected! Closing as behaves correctly.
Note You need to log in before you can comment on or make changes to this bug.