Bug 20315

Summary: Memory leak with Canvas getImageData
Product: WebKit Reporter: James Urquhart <jamesu>
Component: JavaScriptCoreAssignee: Oliver Hunt <oliver>
Status: RESOLVED FIXED    
Severity: Normal CC: oliver
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
URL: http://www.cuppadev.co.uk/assets/canvas-quirk.html
Attachments:
Description Flags
Fixeration mjs: review+

James Urquhart
Reported 2008-08-07 02:06:39 PDT
I seem to be getting a rather predictable memory "leak" when using getImageData() on a 2d Canvas Rendering Context. Basically in my test case, i am calling putImageData(getImageData(...), ...) every chance i can get. Memory usage climbs well into the 1 <-> 2gb range. It should be noted that this occurs in other browsers too, though with varying cut-off points (presumably when the garbage collection finally kicks in). However it should also be noted that i am essentially running the same code in a real app, i don't seem to encounter this issue (in WebKit r35620). For reference, i have put a copy of this up at the following URL: http://www.cuppadev.co.uk/hiscumm/webkit-canvas-mem/js_test.html (search for "fastPaletteRemap" if you want the meat of it) As for why this is, i am really stumped. So i can't really rely on it. Any insight would be appreciated of course. :)
Attachments
Fixeration (14.28 KB, patch)
2008-10-01 21:41 PDT, Oliver Hunt
mjs: review+
Eric Seidel (no email)
Comment 1 2008-09-30 20:41:27 PDT
Ouch.
Geoffrey Garen
Comment 2 2008-09-30 20:44:44 PDT
JSImageData::JSImageData just needs to call JSC::Heap::reportExtraCost.
Oliver Hunt
Comment 3 2008-09-30 21:41:46 PDT
JSCanvasPixelArrayCustom already does that -- i suppose if you never used the CPA that would achieve this result but, if you ever did touch it it would report... Hmmmm -- i wonder if we ever get rid of the cached wrapper though?
Oliver Hunt
Comment 4 2008-10-01 21:41:30 PDT
Created attachment 24004 [details] Fixeration Fix
Maciej Stachowiak
Comment 5 2008-10-01 21:43:02 PDT
Comment on attachment 24004 [details] Fixeration r=me
Oliver Hunt
Comment 6 2008-10-01 22:02:54 PDT
Committing to http://svn.webkit.org/repository/webkit/trunk ... D WebCore/bindings/js/JSCanvasPixelArrayCustom.cpp M WebCore/ChangeLog M WebCore/WebCore.xcodeproj/project.pbxproj A WebCore/bindings/js/JSImageDataCustom.cpp M WebCore/bindings/scripts/CodeGeneratorJS.pm M WebCore/html/CanvasPixelArray.idl M WebCore/html/ImageData.idl Committed r37181
Note You need to log in before you can comment on or make changes to this bug.