Open
Bug 1255568
Opened 9 years ago
Updated 2 years ago
Memory footprint of web game grows between every hard refresh
Categories
(DevTools :: Memory, defect, P3)
DevTools
Memory
Tracking
(Not tracked)
NEW
People
(Reporter: jsantell, Unassigned)
Details
Attachments
(4 files)
Working on one of our partner's games, I'm noticing the memory footprint grow inbetween refreshes, as if something isn't being cleaned up in the platform.
STR:
1: open memory tools, enable allocations
2: Go to http://tanx.playcanvas.com (or can provide local source privately)
3: Wait til your tank spawns, take a snapshot
4: Take note of the size of snapshot
5: Hard refresh and go back to step 3
On every repetition, the footprint seems to grow by ~20MB and the current views aren't clear on where the issue is (seems to be a lot of things without allocation stacks, or everything grows proportionally). The SavedFrames count seems to get higher than I expected. Recording allocation stacks doesn't seem to make a difference.
I'll attach two snapshots that are from an example first load, and the corresponding 10th or so load, with a difference of 25MB vs 250MB or so.
Reporter | ||
Comment 1•9 years ago
|
||
First snapshot taken after game is loaded in a new tab.
Reporter | ||
Comment 2•9 years ago
|
||
Nevermind, subsequent snapshots are too large to attach on here. But it is recreateable.
Reporter | ||
Updated•9 years ago
|
Has STR: --- → yes
Comment 3•9 years ago
|
||
Comment 4•9 years ago
|
||
Comment 5•9 years ago
|
||
I can repro without enabling allocation stack recording.
Comment 6•9 years ago
|
||
5 refreshes, with allocation stacks: http://media.fitzgeraldnick.com/dumping-grounds/tanx-with-stacks.fxsnapshot
The original was ~20mb, this is ~75mb. Dominator tree shows that most of the memory is tied up in some kind of `window.app.assets` structure, and much of the children dominated by that were allocated in a `_parseAssets` method. I think this is a legit leak in Tanx itself, but it is hard to make further progress without the unminified source.
Can we find people who originally wrote this, debug it with them, and write up a case study?
Flags: needinfo?(jsantell)
Reporter | ||
Comment 7•9 years ago
|
||
Building the unminified source to get more info; I'll reach out to them, I think they'll be at GDC next week.
Flags: needinfo?(jsantell)
Comment 8•9 years ago
|
||
I have seen this behavior as well on a visualization I've been running the memory tool on a bunch. You can see in the dominator tree view there is an "objects > Function" with retained sizes of 13mb and 10mb respectively. These are both retained between refreshes.
Live URL: http://gregtatum.com/poems/wandering-lines/
Code: https://github.com/TatumCreative/wandering-lines
Recording allocation stacks on the un-minified code it looks like this is what is being retained:
https://github.com/TatumCreative/wandering-lines/blob/master/index.js#L170-L174
Is the requestAnimationFrame somehow retaining the reference between refreshes?
Comment 9•9 years ago
|
||
Each refresh uses a different JSCompartment, meaning that it gets a different global object, JSScripts are recreated, etc... It should be impossible for something in the new compartment to reference and hold alive anything from the old compartment.
Updated•9 years ago
|
Priority: -- → P3
Reporter | ||
Comment 10•9 years ago
|
||
Seeing it here too: https://wfwalker.github.io/mc-choir/
This just decodes a handful of small mp3s as arraybuffers -- it looks like the arraybuffers stick around when using the tool. In about:memory, the window stays alive long after the tab is closed, and with it arraybuffers from several refreshes. Does not happen if you don't use the tool. I think this should be a higher priority since this could be sucking up memory long after a developer is done debugging.
This page uses services workers, so that could play a part, but the mp3s cached are small; its the decoded arraybuffers that get huge. These could be platform bugs, but starting to feel like the tool is causing it.
Comment 11•9 years ago
|
||
(In reply to Jordan Santell [:jsantell] [@jsantell] (Please needinfo) from comment #10)
> Seeing it here too: https://wfwalker.github.io/mc-choir/
>
> This just decodes a handful of small mp3s as arraybuffers -- it looks like
> the arraybuffers stick around when using the tool. In about:memory, the
> window stays alive long after the tab is closed, and with it arraybuffers
> from several refreshes. Does not happen if you don't use the tool. I think
> this should be a higher priority since this could be sucking up memory long
> after a developer is done debugging.
>
> This page uses services workers, so that could play a part, but the mp3s
> cached are small; its the decoded arraybuffers that get huge. These could be
> platform bugs, but starting to feel like the tool is causing it.
In this test case, it is ArrayBuffers that are leaking as we keep refreshing. All of them are considered roots with a mJSChannels[i] edges which is something related to media. Looks like this is a platform leak to me. I tried doing an about:memory "minimize memory usage" and it had no effect.
https://dxr.mozilla.org/mozilla-central/search?tree=mozilla-central&q=mJSChannels
Paul, any idea why repeatedly refreshing the page from comment 10 would lead to ArrayBuffer objects being retained for a long time via mJSChannels[i] edges?
Flags: needinfo?(padenot)
Comment 12•9 years ago
|
||
Probably a bug ? I think those would be from `decodeAudioData` or something.
Flags: needinfo?(padenot)
Updated•6 years ago
|
Product: Firefox → DevTools
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•