Bug 53870 - Memory issue using NavigationPage.SetTitleIcon
Summary: Memory issue using NavigationPage.SetTitleIcon
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.4
Hardware: PC Windows
: Normal major
Target Milestone: ---
Assignee: Paul DiPietro [MSFT]
Depends on:
Reported: 2017-03-23 18:30 UTC by christine.blanda
Modified: 2017-03-31 14:04 UTC (History)
3 users (show)

Is this bug a regression?: Yes
Last known good build:

Sample app (239.87 KB, application/x-zip-compressed)
2017-03-23 18:30 UTC, christine.blanda
Profiler file (3.04 MB, application/x-zip-compressed)
2017-03-23 18:32 UTC, christine.blanda

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 for Bug 53870 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description christine.blanda 2017-03-23 18:30:39 UTC
Created attachment 20768 [details]
Sample app

App crashes after viewing 4-6 pages when an image is set using NavigationPage.SetTItleIcon.

Run the attached sample app.  It brings up a list of announcements.  Tap on one, then tap the back arrow to return to the previous list.  Tap on another announcement, then tap the back arrow again.  Repeat this a few more times, and the app will crash.  

There is a variable in AnnouncementPage.xaml.cs _useTitleImage set to true.  Change that to false and the app won't crash.  The difference is text is now being set into the Title field rather than an image in SetTitleIcon.
            if (_useTitleImage)
                NavigationPage.SetTitleIcon(this, "main_logo.png");
                Title = "Memory Test";

Set _useTitleImage back to true and change to the latest stable release of Forms.  Repeat the test and the app will no longer crash.
Comment 1 christine.blanda 2017-03-23 18:32:36 UTC
Created attachment 20769 [details]
Profiler file
Comment 2 Paul DiPietro [MSFT] 2017-03-24 01:44:27 UTC
Can you confirm that this doesn't occur using the latest nightly build (https://blog.xamarin.com/try-the-latest-in-xamarin-forms-with-nightly-builds/)? It looks that way for me (stable doesn't crash, prerelease crashes, nightly doesn't).
Comment 3 christine.blanda 2017-03-28 14:17:06 UTC
With the latest nightly build(s) I'm getting an exception on startup:
System.InvalidCastException: Specified cast is not valid.
Comment 4 christine.blanda 2017-03-31 14:04:40 UTC
I am getting the same InvalidCastException with nightly build 76.