如何检查Xamarin.Android中的内存泄漏? [英] How to check memory leak in Xamarin.Android?

查看:188
本文介绍了如何检查Xamarin.Android中的内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以分享使用Xamarin Studio在Xamarin.Android平台中检查内存的建议或方法吗?

Could anyone share suggestions or ways to check memory in the Xamarin.Android platform using Xamarin Studio?

我尝试使用Xamarin Studio中可用的以下选项,

I have tried with the below option available in Xamarin Studio,

工具>仪器>分配

但是在这种情况下,我只能在下图中的选项中选择iOS设备,

But in that, I can select only iOS devices in the options as in below image,

对此有什么解决办法吗?

Is there any solution for this?

推荐答案

很遗憾,但是您不能以任何可靠的方式在Xamarin Studio中进行此操作.您可以尝试探查器,但它需要企业许可证.我的建议是使用标准的Android工具.

Sadly, but you can't do it from Xamarin Studio in any reliable way. You can try profiler, but it requires Enterprise license. My suggestion is to use standard Android tools.

准备:

1)下载"Eclipse内存分析器"

2)找到Android设备监视器.与Android SDK捆绑在一起,可以在"Android-SKD/tools/monitor"中找到.您可以通过打开Xamarin,按CMD +并选择SDK位置来找到该文件夹​​的位置.

2) Find Android Device Monitor. Bundled with Android SDK and can be found at "Android-SKD/tools/monitor". You can find out location of that folder by opening Xamarin, pressing CMD + , and selecting SDK Locations.

3)查找堆快照转换器(从Android到Java).捆绑了Android SDK,可以在"Android-SDK/platform-tools/hprof-conv"中找到

3) Find Heap Snapshot converter (from Android to Java). Bundled with Android SDK and can be found at "Android-SDK/platform-tools/hprof-conv"

捕获:

1)在设备上以调试模式安装应用程序

1) Install application with debug mode on device

2)将设备连接到PC并启动监视器(准备工作需要2步)

2) Connect device to PC and launch monitor (2 step at preparation)

3)启动应用程序,并通过设备中的应用程序ID找到它.

3) Launch the application and find it by application ID in devices.

4)按Update Heap(错误图标右侧的图标)

4) Press Update Heap (icon to the right from bug icon)

5)做一些你认为会导致泄漏的事情

5) Do stuff that you think makes leaks

6)按下Save Heap(开始右边的图标)并将其保存到驱动器中

6) Press Save Heap (icon to the right of start) and save it to the drive

检索结果:

1)将android堆转换为Java堆

1) Convert android Heap to Java Heap

1.1)启动终端

1.2)找到堆Shanpshot转换器(hprof-conv)(准备工作需要3个步骤)

1.2) Locate Heap Shanpshot converter (hprof-conv) (3 step at preparation)

1.3)将hprof-conv拖放到终端

1.3) drop hprof-conv to terminal

1.4)删除Android堆,然后再将其删除并重命名.它将在与所选名称相同的位置创建正确的副本

1.4) drop Android heap, and then, drop it next and rename it. It will create correct copy in the same location with chosen name

android-sdk-macosx/platform-tools/hprof-conv raw.hprof converted.hprof

2)打开Eclipse内存分析器(准备阶段为第一步)

2) Open Eclipse Memory Analyzer (1 step at preparation)

3)导入获取的Head Dump

3) Import acquired Head Dump

3)选择泄漏可疑报告

3) Select Leak Suspects Report

4)查看结果

这篇关于如何检查Xamarin.Android中的内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆