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