-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
perf/memory-leak 💦Memory usage grows / objects live forever (sub: perf)Memory usage grows / objects live forever (sub: perf)platform/windowss/no-reproCan no longer be reproduced on latestCan no longer be reproduced on latests/triagedIssue has been reviewedIssue has been reviewedt/bugSomething isn't workingSomething isn't working
Description
Description
I need to get the height and width of an image. According to the example article on Microsoft Learn, I use the PlatformImage class. When loading a 2.40 MB photo 10 times (I need to know the sizes of several images), the application's RAM consumption grows to 400 MB! When I click again(grows to 900 MB), the memory is not cleared (despite the request for garbage collection and using), the memory occupied continues to increase and is not cleared.
On Android everything works very slowly.
memory.leak.mp4

Steps to Reproduce
1.Download sample image
2. Create MAUI project
3. Change MainPage.xaml.cs to:
using Microsoft.Maui.Graphics.Platform;
namespace MauiApp1
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void OnCounterClicked(object? sender, EventArgs e)
{
string path = @"PXL_20250503_113944303.jpg";// path to example image
for (int i = 0; i < 10; i++)
{
using (FileStream picDataForMeta = new FileStream(path, FileMode.Open, FileAccess.Read))
{
using var img = PlatformImage.FromStream(picDataForMeta);
}
}
GC.Collect();
}
}
}
- Set the path to the downloaded image to the variable "path"
- Run app and click button "Click me"
Link to public reproduction project repository
No response
Version with bug
9.0.30 SR3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
No response
Affected platforms
Android, Windows
Affected platform versions
Android 13, Android 16, Windows 10
Did you find any workaround?
No response
Relevant log output
Metadata
Metadata
Assignees
Labels
perf/memory-leak 💦Memory usage grows / objects live forever (sub: perf)Memory usage grows / objects live forever (sub: perf)platform/windowss/no-reproCan no longer be reproduced on latestCan no longer be reproduced on latests/triagedIssue has been reviewedIssue has been reviewedt/bugSomething isn't workingSomething isn't working