IOS HTML Rich Text rendering method: Dtcoretext, Wkwebview, UIWebView memory footprint Comparison

Source: Internet
Author: User

In the app's content page (Detail page), Rich text display has always been a problem to deal with, and usually in the back-end Rich text editing, HTML application is more common, so actually need to deal with the HTML Rich text display problem, the following three ways is certainly not the best way to display HTML Rich text, Just a relatively simple solution, the conversion requirements for the front and back end are small and can be quickly integrated.

The following 3 ways to test the memory of the comparison, after all, the details page is relatively large, and open the high frequency of the page, so memory consumption is a must consider the problem.

Basic Environment:
    • Objective-c
    • Xcode 6.4
    • Deployment Target IOS 8.0
    • Dtcoretext version: 1.6.16
Description
    • Dtcoretext: Third-party Rich text display component, support HTML conversion to nsattributedstring;
    • Wkwebview:ios's WebKit framework for browser components, starting with IOS 8.0 support;
    • Uiwebview:ios's Uikit framework for browser components, starting with IOS 2.0 support;
Test method:
    1. Use 3 components to display the contents of a Web page (for example: http://news.dayoo.com/guangzhou/201512/11/139995_45489706.htm);
    2. After loading the page, empty the content, load the content again, repeat 3 times;
    3. Compare the memory consumption of 3 components;
Memory Debug Tool: Instruments Test Result: Dtcoretext wkwebview UIWebView

Memory consumption at run time: Dtcoretext < Wkwebview < UIWebView
Memory consumption at end of run: Wkwebview < Dtcoretext < UIWebView

UIWebView has been criticized by the memory of the problem is still unresolved, if you need to open the HTML page more complex (especially with a lot of JS) or use it cautiously, the new wkwebview really better than UIWebView in memory management, if the app can abandon iOS 7 Or the following version, worth using, at least in memory footprint has been with the original nsattributedstring gap is not so big, in iOS device memory and performance higher, the gap will be smaller, and pure HTML page flexibility will be higher.

Before using UIWebView, tried various methods of releasing memory, including setting Nsurlcache, emptying Nsurlcache and other methods, but the actual role is not very much, so in the test did not use these methods, just use the [_webcontent Loadhtmlstring:nil Baseurl:nil]; to clear the content;



Lnmp_ios Small set of TUMG
Links: Https://www.jianshu.com/p/9f5ac4d47ef4
Source: Pinterest
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

IOS HTML Rich Text rendering method: Dtcoretext, Wkwebview, UIWebView memory footprint Comparison

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.