Closed
Bug 651531
Opened 14 years ago
Closed 14 years ago
A single page-worker.Page can only load ~2630 pages before NS_ERROR_OUT_OF_MEMORY from evalInSandbox
Categories
(Add-on SDK Graveyard :: General, defect, P2)
Tracking
(Not tracked)
RESOLVED
FIXED
1.0
People
(Reporter: jwatt, Assigned: ochameau)
References
()
Details
(Keywords: memory-leak)
Attachments
(2 files)
2.24 KB,
text/javascript
|
Details | |
597 bytes,
patch
|
irakli
:
review+
|
Details | Diff | Splinter Review |
Spinning this off from bug 642306.
It doesn't seem to be possible to reuse a single page-worker.Page (setting its 'contentURL' property to about:blank?<incremented>) more than ~2630 times before setting the property causes the following console output, preventing the Page instance from being used again:
error: An exception occurred.
Traceback (most recent call last):
File "resource://jid0-r5rj13fz1ughflxgwp9cwfttvfe-api-utils-lib/observer-service.js", line 174, in null
this.callback(subject, data);
File "resource://jid0-r5rj13fz1ughflxgwp9cwfttvfe-api-utils-lib/content/symbiont.js", line 191, in _onStart
this._onInit();
File "resource://jid0-r5rj13fz1ughflxgwp9cwfttvfe-api-utils-lib/content/worker.js", line 340, in Worker
WorkerGlobalScope(this); // will set this._port pointing to the private API
File "resource://jid0-r5rj13fz1ughflxgwp9cwfttvfe-api-utils-lib/traits.js", line 142, in Trait
return self.constructor.apply(self, arguments) || self._public;
File "resource://jid0-r5rj13fz1ughflxgwp9cwfttvfe-api-utils-lib/content/worker.js", line 179, in WorkerGlobalScope
Cu.evalInSandbox(es5code.contents, sandbox, "1.8", es5code.filename);
[Exception... "Component returned failure code: 0x8007000e (NS_ERROR_OUT_OF_MEMORY) [nsIXPCComponents_Utils.evalInSandbox]" nsresult: "0x8007000e (NS_ERROR_OUT_OF_MEMORY)" location: "JS frame :: resource://jid0-r5rj13fz1ughflxgwp9cwfttvfe-api-utils-lib/securable-module.js -> resource://jid0-r5rj13fz1ughflxgwp9cwfttvfe-api-utils-lib/content/worker.js :: WorkerGlobalScope :: line 179" data: no]
There's a test add-on at http://hg.jwatt.org/page-worker-leak/ - click on the red add-on icon to start/stop loading about:blank into the Page singleton. Hover over the red icon to see the current load count.
I'm using an early 2011 MacBook Pro with 8 GB of RAM, and I have tons of RAM free when the NS_ERROR_OUT_OF_MEMORY exception is thrown.
Updated•14 years ago
|
Priority: -- → P2
Target Milestone: --- → 1.0
Assignee | ||
Comment 1•14 years ago
|
||
I think I finally found why Page worker was leaking when we reuse one existing instance. I think some stuff was leaking like in Widget in bug 652530.
Then we are leaking various objects from Worker.js as we do not call Worker._workerCleanup. It should be called on document unload but may be it's too late or do not happens on location change ... But if we call it manually, this leaks appears to be fixed.
# Without bug 652530 patch, nor following patch:
Memory used before/after changing worker location 500 times:
before: 39896184
after : 43605476
Assignee: nobody → poirot.alex
Assignee | ||
Comment 2•14 years ago
|
||
Simply call Worker._workerCleanup from page worker code before loading a new content script in the new document.
# With 652530 patch, and this additional fix:
Memory used before/after changing worker location 500 times:
before: 39963652
after : 42648984
Jonathan: Can you confirm that this leak is finally fixed by applying both patches ?
Attachment #531745 -
Flags: review?(rFobic)
Reporter | ||
Comment 3•14 years ago
|
||
Woo! Confirmed! Quick test got to over 100,000 loads in the same worker, with no noticeable increase in Firefox memory, and no NS_ERROR_OUT_OF_MEMORY exception. :)
Comment 4•14 years ago
|
||
Comment on attachment 531745 [details] [diff] [review]
Fix this leak.
Review of attachment 531745 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks Alex, looks good!
Attachment #531745 -
Flags: review?(rFobic) → review+
Assignee | ||
Comment 5•14 years ago
|
||
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Reporter | ||
Updated•14 years ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•