Summary: | Serializing a jQuery Object with jsDump can often kill the computer | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Martin Häcker <spamfaenger> | ||||||
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> | ||||||
Status: | UNCONFIRMED --- | ||||||||
Severity: | Normal | CC: | mrowe | ||||||
Priority: | P2 | Keywords: | InRadar | ||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | PC | ||||||||
OS: | OS X 10.5 | ||||||||
Attachments: |
|
Description
Martin Häcker
2009-10-19 04:43:24 PDT
Can you please attach a simple test page that demonstrates the problem? Created attachment 41489 [details]
Showcase of the memory leak
I was able to reproduce the memory leak situation in this small setup - however I was not able to reduce the "brings my computer to a complete halt" scenario yet.
Sorry - I know it has to be a very similar situation, but I haven't found the magic sauce yet.
Something I observed while trying this out: It seems that this code leaks even more memory even after the "slow script warning" is used to kill this errant java-script. I will not pursue this further as I don't have the time, but it might make sense to monitor WebKit even after the script is killed.
Regards,
Martin
I suspect that this stems from the fact that $('dl').sortable().data('sortable’) returns a self-referential data structure. $('dl').sortable().data(‘sortable’).containers[0] === $('dl').sortable().data('sortable’). Code that attempted to process this data structure without handling recursion would demonstrate the behavior you mention. The sample page doesn’t appear to work in Firefox which makes it hard to determine whether we’re doing something wrong or if the script is at fault. Firefox throws an exception saying: $("dl").sortable is not a function. After tweaking it a little bit more I managed to convince this to work in Firefox too. Firefox dies saying: Error: too much recursion Source File: http://flesler-plugins.googlecode.com/files/jsDump-1.0.0.js Line: 45 This indicates that the code in jsDump is at fault for not handling data structures with cycles correctly. I suspect WebKit uses more memory and runs in to the slow script dialog before it hits its much higher maximum recursion depth (> 45,000 compared to Firefox’s 3,000). Created attachment 41490 [details]
Test that works in Firefox
Some quick tests on my part confirm this analysis. I would think that what webkit needs is some kind of limit that brings up the slow-script-warning before the memory use brings down the system to a screetching and complete halt. I would imagine something like if a webpage uses more than half the complete ram of the system could be the point when a dialogue offering to stop the script could be shown. (Probably even way before that) Regards, Martin |