NEW33732
<canvas>.getContext('2d') seems to never free memory
https://bugs.webkit.org/show_bug.cgi?id=33732
Summary <canvas>.getContext('2d') seems to never free memory
Simo Kinnunen
Reported 2010-01-15 12:57:00 PST
Created attachment 46705 [details] Example Memory allocated for CanvasRenderingContext2D never gets freed. Simply calling getContext('2d') and never doing anything with it nor its <canvas> will eat all your memory. See the attachment for a simple example (and remember to monitor your memory usage). Creating a canvas element by itself (without accessing the rendering context) doesn't leak any memory. Firefox exhibits the same "nom nom nom" behavior, but - unlike WebKit - frees the gobbled up memory after a while. I do not know the inner workings of the canvas element, but I take it that there is a reason why neither WebKit nor Firefox free the memory immediately when [from my point of view] it's no longer in use at all; I hope someone can educate me on this one. Would it at least be possible to implement some kind of timed garbage collection?
Attachments
Example (301 bytes, text/html)
2010-01-15 12:57 PST, Simo Kinnunen
no flags
Oliver Hunt
Comment 1 2010-01-15 13:37:13 PST
Curiously we _do_ do periodic gc, so i wander what's happening. The logical conclusion is that the canvas is remaining live for some reason...
Oliver Hunt
Comment 2 2010-01-15 13:37:33 PST
(i haven't verified that i see the leakage however)
Sam Weinig
Comment 3 2010-01-15 16:27:06 PST
(In reply to comment #1) > Curiously we _do_ do periodic gc, so i wander what's happening. The logical > conclusion is that the canvas is remaining live for some reason... I don't believe we actually do a periodic gc. We do a gc on navigation though.
Simo Kinnunen
Comment 4 2010-02-18 00:30:56 PST
Would someone mind at least confirming the issue?
Adam Barth
Comment 5 2010-02-18 00:40:49 PST
Sure, but we don't usually differentiate between the UNCONFIRMED and the NEW state.
Alexey Proskuryakov
Comment 6 2010-11-23 23:06:14 PST
Is the issue perhaps that CanvasRenderingContext2D doesn't call reportExtraMemoryCost()?
Note You need to log in before you can comment on or make changes to this bug.