本文介绍了MVVMCross-SqlBits内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发具有MVVMCross的Monotouch应用程序,该应用程序类似于SqliBits示例(UINavigationCOntroller具有一个选项卡控制器,并且在该选项卡控制器内部还有一个导航控制器).似乎内存已分配但从未释放.

We are developing an Monotouch application with MVVMCross similar to SqliBits sample (the UINavigationCOntroller has a tab controller and inside the tab controller there is anothe navigation controller). It seems that the memory gets allocated but never released.

要重现此错误,请使用探查器选择会话"选项卡启动SqliBits示例,然后选择返回一天",选择返回一天" ...,然后查看内存分配,您将看到已分配了内存但从未发布.

To reproduce this error launch the SqliBits sample with the profiler select Sessions tab and then select a day go back, select a day go back,... and then look at the memory allocation and you will see that trhe memory gets allocated but never released.

我仍然可以附加图像,但是重现错误非常容易.

I am allowed to attach an image yet but it is fairly easy to reproduce the error.

关于,丹

推荐答案

作为一个问题,已经在 https://github.com/slodge/MvvmCross/issues/19

As an issue, this has been discussed on https://github.com/slodge/MvvmCross/issues/19

iOS仅在内存不足时(通过View Controller ViewDidUnload方法)释放视图-在模拟器中,这可以从硬件"菜单中人为创建.

iOS only frees up Views (via View Controller ViewDidUnload method) when there is a memory shortage - within the Simulator this can be artificially created from the Hardware menu.

除此之外,还存在少量内存泄漏,这似乎是由于在RelayCommand的操作"字段中对ViewModel的引用引起的.我尚不完全清楚是什么原因造成的,但是将Dispose方法添加到RelayCommand会使此Action为null似乎已解决了问题(请参见 https://github.com/slodge/MvvmCross/commit/8fc1af3fc9960445b5358daf8111f6bc9683b907 )

Beyond this, there was also a small memory leak which looks like it was caused by a reference to the ViewModel in the Action fields within the RelayCommand. It's not entirely clear to me what caused this, but adding Dispose methods to the RelayCommand which nulls this Action seems to have removed the problem (see https://github.com/slodge/MvvmCross/commit/8fc1af3fc9960445b5358daf8111f6bc9683b907)

这篇关于MVVMCross-SqlBits内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 22:37