Bug 55482 - WrapLayout memory issue
Summary: WrapLayout memory issue
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-04-22 07:19 UTC by eusebiu.marcu
Modified: 2017-05-04 22:42 UTC (History)
2 users (show)

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


Attachments
Test project (254.85 KB, application/zip)
2017-04-22 07:19 UTC, eusebiu.marcu
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 ANSWERED

Description eusebiu.marcu 2017-04-22 07:19:21 UTC
Created attachment 21718 [details]
Test project

I am using the WrapLayout from here: https://github.com/conceptdev/xamarin-forms-samples/blob/master/Evolve13/Evolve13/Controls/WrapLayout.cs

The problem is that the memory consumption is huge (as seen in Xamarin Profiler) when the items are containing an image.

I attached a test project to reproduce this issue.

OS: iOS 10.3
XF: 2.3.4.231
Comment 1 Jimmy [MSFT] 2017-05-04 22:42:56 UTC
Thank you for filing this report!

I ran the project you attached and I could see the high memory usage you mentioned. However I noticed that the resolution of some of the image resources in the project are very large. For example, the PowerPoint icon shows as being 2000 x 2000. This is not recommenced because the image will be decoded at the full resolution and use more memory even though it will be scaled down when rendered.

To test this, I changed the items IconSource to the star.png also included in the project and I saw a significant reduction in memory usage. I would suggest optimizing your images for multiple resolutions in order to avoid potential memory issues. You can see more info here[1][2]. I would also recommend checking out the newer WrapLayout sample here[3] as the original was based on an older version of Xamarin.Forms.

If you continue seeing significant memory usage after doing the above, please re-open this report and include an updated project. Thanks!

[1] https://developer.xamarin.com/guides/xamarin-forms/deployment-testing/performance/#Optimize_Image_Resources
[2] https://developer.xamarin.com/guides/cross-platform/deployment,_testing,_and_metrics/memory_perf_best_practices/#Optimize_Image_Resources
[3] https://developer.xamarin.com/samples/xamarin-forms/UserInterface/CustomLayout/WrapLayout/