High memory usage on UWP when resizing #1616
Replies: 6 comments 3 replies
-
The |
Beta Was this translation helpful? Give feedback.
-
@mattleibow are you able to reproduce this? |
Beta Was this translation helpful? Give feedback.
-
I had a look and there are some interesting things that happen. For a start, I create the page and resize it as small as it can go. After a few minutes, the GC kicks in and reduces the memory usage to 36 MB. From this base point, I maximize to a full screen: 3840x2160 at 250% scaling. A few things happen:
In total, there is an additional 58.22MB from the base 36MB bringing the total to 94.22MB. I tried again after doing things and it went from 110MB to 176MB (+66MB) and after a second, down to 147MB (-29MB). When drag-resizing, there also seems to be this double render issue. At this point, it appears that due to scaling, the view's size is getting the decimal point sizes due to scaling, but then settles down to integer values when you release. However, after a few minutes the GC will kick in and release the backing bitmaps and the usage drops down to the starting value. This also happens on WPF due to the fact that I actually do not control the bitmap, it is the framework that does it. And, unfortunately, there does not appear to be a way to request that the bitmaps be disposed immediately. |
Beta Was this translation helpful? Give feedback.
-
Not recommended, but you can try: System.GC.Collect(); |
Beta Was this translation helpful? Give feedback.
-
Or if you really want to get nasty:
|
Beta Was this translation helpful? Give feedback.
-
I got a basic sample here and tried something bad. When you start the app, spam the GC. It drops to 36MB. I then resize like crazy and get it up to 700MB. After spamming the GC, it drops right down to 36MB again. Another thing is that the GC seems to be some sort of tiered or slow async version. If you watch the GC collect, it is going in steps. Even between manual GCs. I have a stack of RAM (32GB) and I wonder what the difference would be on a 2 or 4GB machine. Will the GC be more aggressive? If you think about it, my GC does not have to be too aggressive because the big 700MB is just 2% of the available. On a 4 GB machine, it will be a 17%, so maybe it will be more aggressive and keep lower? |
Beta Was this translation helpful? Give feedback.
-
Tested on latest SkiaSharp release, on fresh blank UWP app with:
The numbers are variable and the high memory usage depends on gradual resizing.
I would expect a SkiaSharp view filling a 1440p screen to take 15MB at most (n. of pixels * 4 bytes).
Beta Was this translation helpful? Give feedback.
All reactions