dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.04k stars 1.17k forks source link

WPF window and images take massive amount of memory compared to UWP #3135

Open teh173 opened 4 years ago

teh173 commented 4 years ago

A WPF window and image seem to take a massive amount of memory compared to an equivalently sized window in UWP.

Possibly related issues:

Test apps for WPF and UWP

WindowMemoryTestApps.zip

  1. Create a window
  2. (optional) Add an image element at the size of the screen. It just increases the memory usage even further than a blank window alone
  3. Resize the window to multiple monitors ( for example, 2 4Ks, or 1 4K monitor and other sized monitors)

Compare the memory usage in WPF vs. UWP

Actual behavior: On my monitor setup with 7495 x 4440 virtual screen pixels, for WPF, sizing a window to that size takes around image

This is what a similar setup looks like in UWP. image

Expected behavior: I would expect the behavior closer to UWP. I would expect say a (3840 x 2160 x 4 bytes per pixel) * 2 monitor setup to take 66,355,200 bytes, but WPF seems to be using many multiples of that.

Is this just an architectural limitation in WPF, or a bug?

simonjstanford commented 3 years ago

We found that this was mainly an issue when debugging an app through Visual Studio and that disabling the in-app toolbar in the Live Visual Tree helped prevent this issue.

baochenw commented 3 years ago

It is not related to i-app bar. The issue could be reproducible with the template project. Please refer to vedio in #4265 https://github.com/dotnet/wpf/issues/4265#issuecomment-843365764