Memory consumption was high when we add an image to canvas

Raja VIGNESH B 0 Reputation points
2023-03-31T13:00:19.5933333+00:00

Hi team,

The memory consumption while adding an image to the canvas in Visual studio 2022 was very high. We are adding the image of size 15mb to the canvas. After adding the image to the canvas, the memory consumption was around 800mb. Please find the code snippet that we have used below,


Grid stampGrid = new Grid();
            stampGrid.Height = 300;
            stampGrid.Width = 400;
            BitmapImage bitmapImage = new BitmapImage(new Uri("Path of the image", UriKind.Absolute));
            System.Windows.Controls.Image image = new System.Windows.Controls.Image();
            image.Source = bitmapImage;
            stampGrid.Children.Add(image);
            canvas.Children.Add(stampGrid);

Please check on this issue.

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,670 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,594 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,228 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
762 questions
{count} votes