On Dec 28, 2011, at 10:09 AM, Stéphane Sudre wrote:
When I use [[NSMutableAttributedString alloc]
initWithHTML:options:documentAttributes:], WebKit is apparently
eating a huge amount of memory if I call this method a lot of times
(like 2,000 with raw HTML data from 100 bytes to 20 KB).
This method is surprisingly expensive. It may sound like a simple
format converter, but it's really building up a whole DOM tree (and
I'm not sure how much else; a WebFrame perhaps?) I try to avoid it
if at all possible.
It's indeed probably doing a lot of things but I simplify the HTML
source as much as possible (like removing the <b></b>, <i></i>, <img>,
<script></script>, etc. tags) before feeding HTML data to the method.
Just to check off the obvious suspects: you're wrapping an
autorelease pool around every iteration of the loop that calls this?
I'm not. I rely on the "event" autorelease pool (I call the method on
the main thread).
I've just tried adding an autorelease pool before the call and
draining it after. The hit on RAM is definitely less huge.
RSIZE is now 125 MB (vs 813 MB).
While this is way better, it's also strange:
I can understand that without a loop autorelease pool, it will reach a
high memory footprint but I don't get why the memory footprint:
(a) does not go down without the loop autorelease pool. As if some
pieces of auto-released data are not detected by the "event" loop when
there are too many of them?
(b) still gets higher and higher with each iteration even with a loop
autorelease pool. Why does it have to reach 125 MB? (A second run in
the same session will make the RSIZE get bigger and then revert to 125
MB).
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webkitsdk-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden