Pages not being GC'd on Android and therefore leaking (using FreshMvvm)

JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭

When investigating memory leaks in our application (which uses FreshMvvm), I think I have uncovered a leak concerning pages not being Garbage Collected after navigating back.

With a simple main BasicPage, from which we navigate to Basic2Page, and then press the back button to navigate back to BasicPage, I am seeing that Basic2Page is not being garbage collected. There are no Commands or other complications on Basic2Page.

I'm detecting the lack of garbage collection by taking a weak reference to Basic2Page in its constructor; latter it can be seen that the object has not been garbage collected.

This GitHub repository demonstrates the behaviour and has more notes.

Has anyone else seen this behaviour? This is potentially a fundamental problem for us as it means that our non-trivial app is leaking a lot! I'm not sure whether it's a FreshMvvm problem or a fundamental Xamarin.Forms issue. I have raised an issue on the FreshMvvm Github repository too.

Versions: FreshMvvm 2.2.0
Xamarin.Forms: 2.3.4.270

=== Visual Studio Community 2017 for Mac ===

Version 7.1.5 (build 2)
Installation UUID: 650b4c91-c7f5-4ee5-ad70-6f178f314906
Runtime:
Mono 5.2.0.224 (d15-3/14f2c81) (64-bit)
GTK+ 2.24.23 (Raleigh theme)

Package version: 502000224

=== NuGet ===

Version: 4.3.0.2418

=== .NET Core ===

Runtime: Not installed
SDK: Not installed
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.5.5
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.0 (11246)
Build 8A218a

=== Xamarin.Android ===

Version: 7.4.5.1 (Visual Studio Community)
Android SDK: /Users/jameslavery/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
2.3 (API level 10)
4.0.3 (API level 15)
4.1 (API level 16)
4.3 (API level 18)
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 26.0.0
SDK Build Tools Version: 26.0.2

Java SDK: /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin.iOS ===

Version: 11.0.0.0 (Visual Studio Community)
Hash: 152b654a
Branch: xcode9
Build date: 2017-09-15 02:25:56-0400

=== Xamarin Inspector ===

Version: 1.3.1
Hash: cbc48dd
Branch: 1.3-release
Build date: Thu, 21 Sep 2017 19:52:53 GMT
Client compatibility: 1

=== Xamarin.Mac ===

Version: 3.6.3.3 (Visual Studio Community)

=== Build Information ===

Release ID: 701050002
Git revision: 7afedcaef8e7542e70e3cf8f9bdb26938b8c0876
Build date: 2017-09-15 08:39:58-04
Xamarin addins: 3262aadf811a18c12eac6742532d052b0139a808
Build lane: monodevelop-lion-d15-3-xcode9

=== Operating System ===

Mac OS X 10.11.6
Darwin 15.6.0 Darwin Kernel Version 15.6.0
Thu Jun 23 18:25:34 PDT 2016
root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Redth's Addins 1.0.9

Sign In or Register to comment.