Bug 44166 - MasterDetailPage instances do not get disposed upon GC; instance accumulation crashes app with OOM error using Forms 2.3.2.118-pre1 and AppCompat
Summary: MasterDetailPage instances do not get disposed upon GC; instance accumulation...
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.3.2
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-09-10 14:13 UTC by Ashley Gazich [MSFT]
Modified: 2016-10-18 15:52 UTC (History)
9 users (show)

See Also:
Tags: Android ac
Is this bug a regression?: ---
Last known good build:


Attachments

Description Ashley Gazich [MSFT] 2016-09-10 14:13:59 UTC
### Customer report

Customer has an Android application using Forms 2.3.2.118-pre1 and AppCompat. The app starts with a login page. After logging in, Application.Current.MainPage is replaced with a new MasterDetailPage. When the user logs out, Application.Current.MainPage is replaced with a new login page. Logging out and back in causes MasterDetailPage instances to accumulate. The accumulating instances also have MasterDetailPages which do not get disposed, which eventually crashes  the app with an out of memory error.

Sample (based on https://bugzilla.xamarin.com/show_bug.cgi?id=40955 AppCompat sample)
https://microsoft-my.sharepoint.com/personal/asgazi_microsoft_com/_layouts/15/guestaccess.aspx?guestaccesstoken=sIBxE4fKBxa5Vmu3y7RiLS9fMQJu3bJs5%2b8tSArgiNs%3d&docid=2_15a0ca616ca664919b8fa73a44e0ae4e0&rev=1


### Steps to reproduce

1. Start the app in Debug mode
2. Press Login
3. Open hamburger menu
4. Press "Contacts" a couple of times
5. Press "Reminders + GC" to do a garbage collect
6. Logout
7. Repeat steps 2-6 a few times
8. Observations from Output window:
- LoginPage instances are disposed
- MasterPage and MainPage counters never go down

Following the above steps, the app should remain on ReminderPage after pressing the Logout button. The ReminderPage count doesn't go below MasterPage and MainPage counts, since the MasterDetailPage instances have a reference to a ReminderPage instance.


### Expected results

MasterPage and MainPage counters decrease upon GC


### Actual results

MasterPage and MainPage counters continue increasing
Comment 1 Ashley Gazich [MSFT] 2016-09-16 22:41:54 UTC
### Customer logcat logs

https://microsoft-my.sharepoint.com/personal/asgazi_microsoft_com/_layouts/15/guestaccess.aspx?guestaccesstoken=8qik20jLnaJ1G7q962sYWKX%2ftNco5b546ZAt68MR3Fg%3d&docid=2_1ea1da305f3c546f5ac1465749782e971&rev=1


### Customer version info

Microsoft Visual Studio Professional 2015
Version 14.0.25425.01 Update 3
Microsoft .NET Framework
Version 4.6.01055

Installed Version: Professional

Windows Phone SDK 8.0 - ENU 00322-50050-97143-AA289
Windows Phone SDK 8.0 - ENU

Visual Basic 2015 00322-50050-97143-AA289
Microsoft Visual Basic 2015

Visual C# 2015 00322-50050-97143-AA289
Microsoft Visual C# 2015

Visual C++ 2015 00322-50050-97143-AA289
Microsoft Visual C++ 2015

AnkhSVN - Subversion Support for Visual Studio 2.6.12735.14
AnkhSVN - Subversion Support for Visual Studio 2.6.12735.14
* Ankh.Package 2.6.12735.14
* Subversion 1.9.2 via SharpSvn 1.9002.3777.76

SharpSvn is linked to: Apr 1.5.1, Apr-util 1.5.4, Cyrus Sasl 2.1.26, eXpat 2.1.0, LibSSH2 1.6.0, OpenSSL 1.0.2d 9 Jul 2015, Serf 1.3.8, SQLite 3.8.11.1, Subversion 1.9.2-SharpSvn, Utf8proc 1.1.5, ZLib 1.2.8
SharpSvn is optionally linked to: Berkeley DB 4.4.20, SharpPlink 0.65.0(SharpSvn)

Application Insights Tools for Visual Studio Package 7.0.20622.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015.1 (Beta8) 14.1.11107.0
ASP.NET and Web Tools 2015.1 (Beta8)

ASP.NET Web Frameworks and Tools 2012.2 4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013 5.2.40314.0
For additional information, visit http://www.asp.net/

Common Azure Tools 1.8
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

GitHub.VisualStudio 1.0
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service 2.0
JavaScript Language Service

JavaScript Project System 2.0
JavaScript Project System

Microsoft Azure Mobile Services Tools 1.4
Microsoft Azure Mobile Services Tools

NuGet Package Manager 3.4.4
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Pendletron.Vsix.LocateInTFS 1.0
Opens the source control explorer for the currently selected item

PreEmptive Analytics Visualizer 1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

Python Tools for Visual Studio 2.2.40623.00
Python Tools for Visual Studio provides IntelliSense, projects, templates, Interactive windows, and other support for Python developers.

Python Tools for Visual Studio - Django Integration 2.2.40623.00
Provides templates and integration for the Django web framework.

Python Tools for Visual Studio - Profiling Support 2.2.40623.00
Profiling support for Python projects.

Sandcastle Help File Builder SHFB
Visual Studio integration for the Sandcastle Help File Builder.
https://GitHub.com/EWSoftware/SHFB

SQL Server Data Tools 14.0.60519.0
Microsoft SQL Server Data Tools

TypeScript 1.8.36.0
TypeScript tools for Visual Studio

Xamarin 4.1.2.18 (fcbe082)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android 6.1.2.21 (1cf254d)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS 9.8.2.22 (f37444a)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 2 Jani Lirkki 2016-09-21 07:37:04 UTC
Still reproducible in latest Xamarin Forms prerelease version 2.3.3.152-pre2.
Comment 3 Parmendra Kumar 2016-10-18 15:52:52 UTC
I have checked this issue with Xamarin.Forms 2.3.3-pre3 and observed that app doesn't crash.

Screencast: http://www.screencast.com/t/nni9aDbA

Hence closing this issue.

Note You need to log in before you can comment on or make changes to this bug.