iPhone: Leak with UIWebView loading Office documents. Any ideas how to avoid it?
Posted
by Thomas Tempelmann
on Stack Overflow
See other posts from Stack Overflow
or by Thomas Tempelmann
Published on 2010-05-06T17:07:45Z
Indexed on
2010/05/10
14:04 UTC
Read the original article
Hit count: 294
While there are already quite a few posts about leaks around UIWebView, mine is a bit more special, I believe, and thus deserves its own post here.
I see a reproducible large leak every time I load a Office document such as a Word or Excel file.
For instance, every time I display a 180KB .doc file, I get a 100KB leak. And that happens with both the simulator and an actual device, running OS 3.1.3.
The leak is not visible with the Leaks instrument but only by looking at the malloc instances via the ObjectAlloc instrument.
Here's a picture from the instruments trace:
I've also made a demo project, UIWebView-Leak.zip, so you can verify this yourself.
To see the leak, use the ObjectAlloc instrument, switch to the view where you see individual allocation objects, and sort by size so that you see the large ones in a group, just like in my picture above. Then view a Office document a few times and find the Malloc objects that keep staying "Live" even after the actual UIWebView has been freed.
Is this a known bug? Or is there any way I can avoid these leaks? I.e, have you successfully shown Office documents on an iPhone withing getting such leaks?
Note: I've reported this as a bug to Apple now, too (ID 7950594)
I am still waiting for someone (including Apple) to confirm this as a true leak or show why it isn't (i.e. that I do something wrong or make wrong assumptions)
© Stack Overflow or respective owner