Closed
Bug 568761
Opened 15 years ago
Closed 15 years ago
WebGL memory leaks
Categories
(Core :: Graphics: CanvasWebGL, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: bjacob, Assigned: bjacob)
References
Details
Attachments
(4 files, 3 obsolete files)
|
20.46 KB,
text/plain
|
Details | |
|
858 bytes,
text/plain
|
Details | |
|
132.89 KB,
application/x-xz
|
Details | |
|
992 bytes,
patch
|
vlad
:
review+
vlad
:
approval2.0+
|
Details | Diff | Splinter Review |
To reproduce, just load this page in Minefield and quit:
http://spidergl.org/example.php?id=1
Console output:
=> mAllocCount: 25619
=> mReallocCount: 3534
=> mFreeCount: 25556 -- LEAKED 63 !!!
=> mShareCount: 26894
=> mAdoptCount: 2545
=> mAdoptFreeCount: 2543 -- LEAKED 2 !!!
To make sure that this was specific to WebGL, I checked several javascript-heavy sites: no leak.
Valgrind (see attachment) reports no definitive leak but rather blocks that are still reachable at exit. Still a big concern.
| Assignee | ||
Comment 1•15 years ago
|
||
This was obtained using this debugger script (firefox -g -d script):
valgrind --leak-check=full --show-reachable=yes $*
| Assignee | ||
Updated•15 years ago
|
Attachment #447938 -
Attachment mime type: application/octet-stream → text/text
| Assignee | ||
Updated•15 years ago
|
Attachment #447938 -
Attachment mime type: text/text → text/plain
| Assignee | ||
Comment 2•15 years ago
|
||
OK, looking at these, they don't look WebGL related :)
But why is it then, that Mozilla's console output only reports leaks when I have loaded WebGL pages?
Comment 3•15 years ago
|
||
Do you need to have the webgl pref set?
Note that valgrind would not report as leaked static objects with dtors whereas our built-in logging obviously would.
| Assignee | ||
Comment 4•15 years ago
|
||
This recently got worse: after playing a few seconds with
http://spidergl.org/example.php?id=9
I get:
=> mAllocCount: 101513
=> mReallocCount: 4503
=> mFreeCount: 93156 -- LEAKED 8357 !!!
=> mShareCount: 47311
=> mAdoptCount: 3847
=> mAdoptFreeCount: 3844 -- LEAKED 3 !!!
| Assignee | ||
Comment 5•15 years ago
|
||
Bah, nevermind my last comment: while trying to answer to comment 3, I disabled webgl and navigate to a few sites, the leak is present everywhere. Seems like we have a big non-webgl-related leak in mozilla-central at the moment.
Comment 6•15 years ago
|
||
Have you tried doing a leak log to see what's leaking?
| Assignee | ||
Comment 7•15 years ago
|
||
The new mochitest (from bug 582053) gives this output at the end. It says we're leaking some WebGLUniformLocation and nsTArray_base objects.
| Assignee | ||
Comment 8•15 years ago
|
||
Re: comment 6: I don't know for sure what a "leak log" is, I am just starting to read https://wiki.mozilla.org/Performance:Leak_Tools
| Assignee | ||
Comment 9•15 years ago
|
||
Here's a leak log generating by setting XPCOM_MEM_LEAK_LOG, starting Minefield and navigating to google.com.
| Assignee | ||
Comment 10•15 years ago
|
||
This is a leak log generated by setting XPCOM_MEM_LEAK_LOG, starting Minefield and navigating to this WebGL test page:
https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/tests/conformance/gl-uniform-arrays.html
Notice that it has 318 lines, as opposed to the google.com log above which has 317 lines. The additional line is:
143 WebGLUniformLocation 56 224 12 4 ( 6.90 +/- 3.16) 143 4 ( 21.41 +/- 11.44)
In conclusion, we seem to have:
- a lot of not-WebGL-related leaks
- at least one WebGL-related leak of WebGLUniformLocation objects
Comment 11•15 years ago
|
||
> - a lot of not-WebGL-related leaks
Those look like the sort of output we sometimes get if the you quit the browser while there are network requests in flight..... If that was not the case, please file a bug.
| Assignee | ||
Comment 12•15 years ago
|
||
ok, see bug 582252.
I have reproduced with the default Minefield start page and made sure that it had finished loading (from a naive end-user perspective).
| Assignee | ||
Comment 13•15 years ago
|
||
Ok so the non-WebGL leaks (as explained in bug 582252) were specific to my profile, and don't happen with a clean profile.
So here's now the leak log output from the WebGL test mentioned above. Now we can see only 2 classes, WebGLUniformLocation and nsTArray_base.
Attachment #460523 -
Attachment is obsolete: true
Attachment #460549 -
Attachment is obsolete: true
Attachment #460552 -
Attachment is obsolete: true
| Assignee | ||
Comment 14•15 years ago
|
||
Aha, here's what Valgrind has to say about this.
The most relevant part seems to be:
==3459== 224 bytes in 4 blocks are definitely lost in loss record 4,468 of 5,447
==3459== at 0x4A0515D: malloc (vg_replace_malloc.c:195)
==3459== by 0x68BD2C3: malloc (nsTraceMalloc.c:1139)
==3459== by 0x8A97ECD: moz_xmalloc (mozalloc.cpp:98)
==3459== by 0x59485A4: mozilla::WebGLProgram::GetUniformLocationObject(int) (mozalloc.h:226)
==3459== by 0x594E181: mozilla::WebGLContext::GetUniformLocation(nsIWebGLProgram*, nsAString_internal const&, nsIWebGLUniformLocation**) (WebGLContextGL.cpp:2075)
==3459== by 0x61839FE: nsICanvasRenderingContextWebGL_GetUniformLocation(JSContext*, unsigned int, long*) (dom_quickstubs.cpp:27951)
==3459== by 0x845AA37: js_Interpret (jsops.cpp:2145)
==3459== by 0x846E659: js_Execute (jsinterp.cpp:891)
==3459== by 0x83D0975: JS_EvaluateUCScriptForPrincipals (jsapi.cpp:4776)
==3459== by 0x5B69EA3: nsJSContext::EvaluateString(nsAString_internal const&, void*, nsIPrincipal*, char const*, unsigned int, unsigned int, nsAString_internal*, int*) (nsJSEnvironment.cpp:1794)
==3459== by 0x58E8CD2: nsScriptLoader::EvaluateScript(nsScriptLoadRequest*, nsString const&) (nsScriptLoader.cpp:764)
==3459== by 0x58E86A0: nsScriptLoader::ProcessRequest(nsScriptLoadRequest*) (nsScriptLoader.cpp:674)
Comment 15•15 years ago
|
||
If we have a refcount leak.. why are we bothering with valgrind. Just look at the refcount balance tree and see where the missing releases might be?
Comment 16•15 years ago
|
||
Then again, simple code inspection indicates that WebGLProgram::GetUniformLocationObject addres the object twice in the cache hit case...
| Assignee | ||
Comment 17•15 years ago
|
||
I'm just learning how to use our leak analysis tools and didn't know how to "look at the refcount balance tree" but will make sure to learn...
I agree with your inspection and am looking at this code now!
Comment 18•15 years ago
|
||
http://www.mozilla.org/performance/leak-tutorial.html has some docs on using the refcount balancer, if you want.
| Assignee | ||
Comment 19•15 years ago
|
||
This fixes the leak. I also can't see why I ever wrote this NS_ADDREF.
Attachment #461025 -
Flags: review?(vladimir)
| Assignee | ||
Comment 20•15 years ago
|
||
(In reply to comment #18)
> http://www.mozilla.org/performance/leak-tutorial.html has some docs on using
> the refcount balancer, if you want.
Thanks for the link!
Comment 21•15 years ago
|
||
You're welcome. Good to see more people looking into leaks!
Comment on attachment 461025 [details] [diff] [review]
Fix webGL leak
I don't know why I reviewed it! Nice catch.
Attachment #461025 -
Flags: review?(vladimir)
Attachment #461025 -
Flags: review+
Attachment #461025 -
Flags: approval2.0+
| Assignee | ||
Comment 23•15 years ago
|
||
| Assignee | ||
Updated•15 years ago
|
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Updated•14 years ago
|
Assignee: nobody → bjacob
You need to log in
before you can comment on or make changes to this bug.
Description
•