Bug 140919
Summary: | WeakMap Object key expected to be garbage collected is not | ||
---|---|---|---|
Product: | WebKit | Reporter: | Joseph Pecoraro <joepeck> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | Normal | CC: | ggaren, joepeck, mark.lam, timothy, webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | 528+ (Nightly build) | ||
Hardware: | All | ||
OS: | All |
Joseph Pecoraro
* 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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Joseph Pecoraro
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
<rdar://problem/19609705>
Joseph Pecoraro
The test and inspector pieces have not landed yet. It is currently up for review on bug 122867.
Joseph Pecoraro
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.