Temporary solution for memory leaks on iOS using www

Source: Internet
Author: User

Original address: http://www.unity Bull. com/thread-16493-1-1.html

At present, in 4.3.3. and 4.3.4, there is a memory leak on the iOS platform, that is, when using www to download and load the Assetbundle file, if the following method is done, it will cause the memory can not be completely released after Assetbundle unload.

In this respect, unity has officially fixed the issue and updated it in the next release. However, for projects that are still being developed using 4.3.3 and 4.3.42 versions, the following temporary solutions are recommended:

Currently, in Unity's 4.3.3. and 4.3There is a memory leak on the iOS platform in version 4, which means that when you use WWW to download and load a assetbundle file, it can cause the memory to not be fully released after Assetbundle uninstall if you do so in the following manner. In this respect, unity has officially fixed the issue and updated it in the next release. But for the time being still using 4.3.3 and 4.3For projects developed on 42 versions, it is recommended to use the following temporary solutions, as follows:1. Publish the Unity project as Xcode project; 2. Files found in the generated Xcode project: classes/unity/wwwconnection.mm;3. Open and look up the function: "externCvoidUnitydestroywwwconnection (void*connection) ";4. Modify the function as follows: [AppleScript] Plain text view copy codeextern"C" Voidunitydestroywwwconnection (void*connection) {Unitywwwconnectiondelegate*Delegate= (unitywwwconnectiondelegate*) connection; [Delegate. Connection Cancel]; Delegate. Connection =Nil; [Delegaterelease]; Modified: [AppleScript] Plain text view copy codeextern"C" Voidunitydestroywwwconnection (void*connection) {Unitywwwconnectiondelegate*Delegate= (unitywwwconnectiondelegate*) connection; [Delegatecleanup]; [Delegaterelease]; }5Next you need to add a cleanup function to find the function first: [AppleScript] Plain text view copy code"- (void) Connection: (nsurlconnection*) connection didreceiveresponse: (Nsurlresponse*response "Then insert the cleanup function above the function with the following function:- (void) Cleanup {[_connection cancel]; _connection=Nil; [_data release]; _data=Nil;} 6after the above modification, the normal release to the device can be. Description:1, the problem exists only on the iOS platform;2, the problem only exists in 4.3.3 and 4.3. On 42 versions,4.3The issue does not exist in. 2 and previous versions;3, another common load api:www. Loadfromcacheordownload does not cause a memory leak problem.

Related Article

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.