Bug 42069 - Garbage Collector can not collect pages that use ImageSource as a StaticResource
Summary: Garbage Collector can not collect pages that use ImageSource as a StaticResource
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-06-22 09:56 UTC by Jacco Dieleman
Modified: 2016-08-04 19:24 UTC (History)
7 users (show)

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


Attachments
Minimal test case (88.45 KB, application/zip)
2016-06-27 06:57 UTC, Jacco Dieleman
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:
VERIFIED FIXED

Description Jacco Dieleman 2016-06-22 09:56:01 UTC
The garbage collector cannot collect pages that use an ImageSource as a StaticResource.
The resource looks like this:
  <Application.Resources>
    <ResourceDictionary>
      <OnPlatform x:TypeArguments="ImageSource" x:Key="SomeSmallImage" Android="foobar.png"/>
    </ResourceDictionary>
  </Application.Resources>

When using the resource like this the page cannot get collected:
<Image Source="{StaticResource SomeSmallImage}"/>

When using the image in the following way, the page does get collected:
<Image Source="foobar.png"/>

When using the sample in the attachment: when you navigate x times from the MainPage to Page1 and back, you have x instances of Page1 in memory.
In the sample Page1 consumes a lot of memory, so the app crashes soon with OOM.
Comment 1 Ashley Gazich [MSFT] 2016-06-24 22:27:00 UTC
@Jacco

Thanks for the report! I have contacted you via our support channel to request additional details.
Comment 2 Jacco Dieleman 2016-06-27 06:57:43 UTC
Created attachment 16497 [details]
Minimal test case
Comment 3 Jacco Dieleman 2016-06-27 06:59:29 UTC
Visual Studio Version Info:
Microsoft Visual Studio Enterprise 2015
Version 14.0.25123.00 Update 2
Microsoft .NET Framework
Version 4.6.01038

Installed Version: Enterprise

Architecture and Modeling Tools   00322-80000-00000-AA526
Microsoft Architecture and Modeling Tools
    
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

Visual Basic 2015   00322-80000-00000-AA526
Microsoft Visual Basic 2015

Visual C# 2015   00322-80000-00000-AA526
Microsoft Visual C# 2015

Visual C++ 2015   00322-80000-00000-AA526
Microsoft Visual C++ 2015

Windows Phone SDK 8.0 - ENU   00322-80000-00000-AA526
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   5.2.60328.3
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015.1 (Beta8)   14.1.11106.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/

CodeMaid   10.1.93
CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.

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

ConfigModuleEditorPackage Extension   1.0
ConfigModuleEditorPackage Visual Studio Extension Detailed Info

InstallShield Limited Edition   
InstallShield. For more information visit the Flexera Software website at <http://www.FlexeraSoftware.com>. Copyright © 2015 Flexera Software LLC. All Rights Reserved.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JetBrains ReSharper Ultimate 2015.1.3   Build 102.0.20150724.141603
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2016 JetBrains, Inc.

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

Multilingual App Toolkit   4.0.1605.0
Multilingual App Toolkit helps you localize your Windows Store app by providing file management, pseudo and machine translation, translation editor, and build integration. http://aka.ms/matinstallv4

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

P4VS - Perforce Plugin for Visual Studio   2016.1.137.8922
P4VS is the Perforce integration for Microsoft Visual Studio. P4VS gives developers working in Visual Studio access to Perforce version control features.  P4VS gives you easy access to all of the Perforce version control tools and information you need to do your daily work. Check out, check in, see history, and more, directly from Visual Studio. P4VS is a fully compliant Visual Studio Integration Package, designed for full compatibility and ease of use. P4VS is built on P4API.NET, Perforce's fully supported API for the .NET environment. Perforce Software provides fast, robust version control to teams of all sizes working on any type of digital asset development.

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

SQL Server Data Tools   14.0.60311.1
Microsoft SQL Server Data Tools

TypeScript   1.8.30.0
TypeScript tools for Visual Studio

Visual Studio Tools for Universal Windows Apps   14.0.25208.00
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Windows Installer XML Toolset   3.10.2.2516
Windows Installer XML Toolset version 3.10.2.2516
Copyright (c) Outercurve Foundation. All rights reserved.

Xamarin   4.1.0.530 (2e39740)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   6.1.0.71 (4e27558)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   9.8.0.323 (39ebb77)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 4 Ashley Gazich [MSFT] 2016-07-07 13:46:10 UTC
Setting back to "new" due to additional information provided.
Comment 5 E.Z. Hart [MSFT] 2016-07-18 16:56:25 UTC
Confirmed in 2.3.1.111-pre2
Comment 6 Samantha Houts [MSFT] 2016-08-02 21:35:22 UTC
Should be fixed in 2.3.2-pre1. Thank you!
Comment 7 Parmendra Kumar 2016-08-04 19:24:19 UTC
I have checked this issue Xamarin.Forms 2.3.2-pre1 and its working fine.

Hence closing this issue.