A few comments. UIWebView "leaks". It runs with at least iOS4. With every large page load, it seems to grow, and memory is not fully restored when the UIWebView object itself is freed. Regardless of whether this memory remains in the cache and when it is really needed, or a leak, I could not answer correctly. This has improved somewhat over the years, but can still be seen using the instrument memory allocation graph.
Let's start with the basics. Before embarking on a design change, try using the tools to see what exactly is happening. You can also subclass your views and view controllers, implement their dealloc methods, and ensure that they are correctly released when expected. Many times, especially when blocks are involved, people create save cycles that cause huge memory leaks. Do it first.
Here are some suggestions for my experience with WebKit:
- Use the web view as much as possible. If you can, use the same object and just add it as a subview of the views of the view controllers.
- We noticed that most of all we could drain from the web view, opening a blank page before releasing the
UIWebView object. - iOS8 supports the new model when working with WebKit:
WKWebView (WebKit2). In this model, web content is managed and distracted from the process, and memory is βleakedβ in the process. If necessary, the OS will kill this WebKit process, which will allow your application to work. You can try this and see if you have any improvements.
source share