MemorySnapshot 是一个用于帮助诊断内存使用情况的分析工具。
MemorySnapshot 以及 UnityEditor.MemoryProfiler.* 中的所有类型都是实验性 API,未来很可能发生显著变化。目前,只有基于 il2cpp 的播放器能够提供内存快照。编辑器和基于单声道的播放器不会响应对新快照的请求。
RequestNewSnapshot | 从性能分析器的当前连接目标请求新快照。内存快照受到 IL2CPP 和 Mono .NET 3.5/4.0 脚本后端的支持,但截至 2018.3 版本,.NET 3.5 已被弃用。 \ \ 注意:每个快照包含每个已记录的托管对象的大约一个托管对象。从编辑器中创建的快照将包含所有先前快照中尚未进行垃圾回收的对象。因此,编辑器的重复快照可能呈指数级增长。如果您不再需要旧快照,则建议取消对它的所有引用,并在再次创建快照之前调用 GC.Collect()。 |
OnSnapshotReceived | 当新内存快照通过性能分析器连接传入时将触发的事件。它的参数将是 PackedMemorySnapshot。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.