Bug 32801 - Memory Leak in TabbedPage + NavigationPage
Summary: Memory Leak in TabbedPage + NavigationPage
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.5.0
Hardware: Macintosh Mac OS
: Normal major
Target Milestone: ---
Assignee: Rui Marinho
URL:
Depends on:
Blocks:
 
Reported: 2015-08-05 12:42 UTC by Zambiorix
Modified: 2016-04-13 18:44 UTC (History)
7 users (show)

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


Attachments
a test project to demonstrate the issue (178.45 KB, application/zip)
2015-08-19 13:00 UTC, Zambiorix
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description Zambiorix 2015-08-05 12:42:43 UTC
In iOS, when the Tab Icon on a TabbedPage is pushed and the current navigation page is not root, then the navigation stack is popped to root (default behavior), but the pages on the navigation stack -that are popped- are not properly released.

When using the back button (popping the navigation pages one by one) they are properly released and are removed from the stack.

With the code below you can inspect the contents of the navigation stack.

When using the Tab Icon, the stack keeps incrementing and the "popped" pages stay on there.

I think this is a memory leak. Visually, everything looks fine, but the popped pages stay in memory and on the navigation stack.


// TODO memory leak -> when tab icon is pushed when not root, the current page is not released

foreach (var item in this.Navigation.NavigationStack)
{
    Console.WriteLine ("Items =====> {0}", item);
}
Comment 1 Paul DiPietro [MSFT] 2015-08-14 13:51:31 UTC
Please pardon my asking, but would it be possible to clarify the sequence of navigation and specific use of the TabbedPage? Some of the wording is perhaps a little ambiguous. For instance, when you say that "when the Tab Icon on a TabbedPage is pushed," by "pushed" do you mean tapped? How is the TabbedPage being specifically used here? If you are also able to create a reproduction project to display the issue as you initially explained it, it would be greatly appreciated in helping to investigate the issue further.
Comment 2 Zambiorix 2015-08-19 13:00:24 UTC
Created attachment 12574 [details]
a test project to demonstrate the issue

a test project to demonstrate the issue
Comment 3 Zambiorix 2015-08-19 13:13:37 UTC
I added a test project to demonstrate the issue



press "add page"

a new page is pushed on the stack, with incrementing level id

press "show navigation stack"

the pages are shown on the stack

all correct




press back button in the navigation header

the page is popped (and destroyed, I force a GC cycle every 100ms to observe faster destroys)

press "show navigation stack"

the remaining pages are shown on the stack

all correct


Issue 1 

press "add page" 5 times in a row

press "show navigation stack"

all pages are on the stack, correctly

now press the tab icon on the bottom of the page

all pages are popped and page with level id = 1 is shown (= default behaviour)

but, non of the popped pages are destroyed and if the stack is shown, they war still there ...

= memory leak



Issue 2

press "add page" 5 times in a row

press "show navigation stack"

all pages are on the stack, correctly

now press back button in the navigation header very quickly until level 1 is shown

some of the popped pages are destroyed, some are not. 

If the navigation stack is shown, some are removed, some are not

= memory leak
Comment 4 Paul DiPietro [MSFT] 2015-09-06 22:38:27 UTC
Thank you very much for adding the project. I can see the issue as you're describing while using 1.5.0.6404-pre3.
Comment 5 Rui Marinho 2015-10-12 06:01:21 UTC
Should be fixed in 1.5.2-pre1
Comment 6 Parmendra Kumar 2015-10-26 07:34:38 UTC
I have checked this issue with Xamarin.Forms 1.5.2-pre1 and I have checked both steps mentioned in bug description and observed that Issue 1 has been been fixed and Issue 2 still occurred.

Hence I am reopening this issue as per Issue 2.

Screencast: http://www.screencast.com/t/0f2cFO8Pvbo

SystemLog: https://gist.github.com/Parmendrak/33d29805cd9afd8eddc0
ApplicationOutput: https://gist.github.com/Parmendrak/68e343eea8567cd4e60a

Environment info:

Xamarin Studio  5.10 (build 848)
Installation UUID: 1a096c6f-0678-402e-89b2-a2c10f7e80e4
Mono 4.2.1 (explicit/fc228e4)
GTK+ 2.24.23 (Raleigh theme)
Package version: 402010084
Xamarin.iOS : 9.2.1.4 (Enterprise Edition)
Mac OS X 10.10.5
Comment 7 Rui Marinho 2016-04-13 18:44:50 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
 
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team