Unity mono run mechanism analysis and memory optimization

Source: Internet
Author: User

First, mono principle

Here is a brief introduction to the next mono this wonderful, mainly through mono can easily achieve cross-platform, the current use of unity development hand-tour Android platform mostly using mono implementation, but the Il2cpp hand tour using the technology. Concrete il2cpp Knowledge everybody can degree Niang.

Second, the memory allocation mechanism

  

Allocation policy for memory, but in this combination of practical experience there is a bug, when allocating large chunks of memory is particularly noticeable, the return and switching applications will crash, mainly because the GC is not timely enough even after the allocation of the manual GC is not immediately released.

Third, the cause of memory leaks

How does mono determine what is used in memory that is no longer needed? is done by referring to the relationship. Mono tracks the action of each memory allocation and maintains a table of allocated objects, which, when GC, is the root node of the global data area and the current register, and is traversed by a referential relationship, marking it as live (alive) for each object that is traversed.

Four, memory optimization

1, the allocation of memory as small as possible, to avoid the application of large chunks of memory, once more large chunks of memory and can not be released, it will cause high memory application crashes.

2, static class objects timely unloading

V. Articles of reference:

[1]http://wetest.qq.com/lab/view/135.html

Unity mono run mechanism analysis and memory optimization

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.