如何采取Xamarin.Android的Mono虚拟机的快照堆? [英] How to take heap snapshot of Xamarin.Android's Mono VM?
问题描述
背景:我试图追查在Xamarin.Android应用程序的内存泄漏。使用DDMS和Eclipse内存分析器,我能看到哪些对象是活的。当试图跟踪拖住他们活着(GC根),我只看到本地堆栈(当然)。
我怎样才能把MONO虚拟机的快照堆?所以,我以后可以用它与IE浏览器heapshot工具?
还是有什么其他的技术,我可以用它来找到拖住对象活着Xamarin.Android的.NET的一部分?是否有可能做一些事情在程序内?
我怎样才能把MONO虚拟机的快照堆?所以,我以后可以用它与IE浏览器heapshot工具?
现在可以得到单VM堆快照(与Xamarin.Android 4.8.2测试版进行测试,可能适用于之前的版本,您的情况可能有所不同)。这是一个四个步骤:
-
启用heapshot记录:
亚行外壳setprop debug.mono.profile日志:heapshot
-
启动应用程序。 (如果你的应用程序是之前已经在运行(1),终止并重新启动它。)
使用你的应用程序。
-
抓斗的轮廓数据为您的应用程序:
亚行拉/data/data/@PACKAGE_NAME@/files/.__override__/profile.mlpd
@PACKAGE_NAME @
是应用程序的包名,例如:如果你的包是FooBar.FooBar-Signed.apk
,然后@PACKAGE_NAME @
将FooBar.FooBar
。 -
分析数据:
mprof-报告profile.mlpd
mprof-报告
附带单。
注意: profile.mlpd
是仅的时候发生GC更新,所以你的可以的要调用 GC.Collect的()
在一些众所周知的点,以确保 profile.mlpd
定期更新。
Background: I am trying to track down a memory leak in a Xamarin.Android app. Using DDMS and Eclipse Memory Profiler, I am able to see which objects are alive. When trying to track what is holding them alive (GC Root), I only see "Native stack" (of course).
How can I take a heap snapshot of the MONO VM? So I can later use it with i.e. heapshot tool?
Or are there ANY OTHER TECHNIQUES I can use to find what is holding an object alive in Xamarin.Android's .NET part? Is it possible to do something from within the program?
How can I take a heap snapshot of the MONO VM? So I can later use it with i.e. heapshot tool?
It is now possible to get heap snapshots of the Mono VM (tested with Xamarin.Android 4.8.2 beta; may apply to prior releases, your mileage may vary). It's a four step process:
Enable heapshot logging:
adb shell setprop debug.mono.profile log:heapshot
Start your app. (If your app was already running before (1), kill and restart it.)
Use your app.
Grab the profile data for your app:
adb pull /data/data/@PACKAGE_NAME@/files/.__override__/profile.mlpd
@PACKAGE_NAME@
is the package name of your application, e.g. if your package isFooBar.FooBar-Signed.apk
, then@PACKAGE_NAME@
will beFooBar.FooBar
.Analyze the data:
mprof-report profile.mlpd
mprof-report
is included with Mono.
Note: profile.mlpd
is only updated when a GC occurs, so you may want to call GC.Collect()
at some "well known" point to ensure that profile.mlpd
is regularly updated .
这篇关于如何采取Xamarin.Android的Mono虚拟机的快照堆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!