Quantcast
Channel: Active questions tagged listview - Stack Overflow
Viewing all articles
Browse latest Browse all 611

WinUI3 ListView seems to hold onto memory of removed items

$
0
0

I have a WinUI3 app in which I use a ListView which might display very few or very many items.

If I populate the ListView with many items, my memory usage goes up from ~250MB to ~1GB. If, however, I then reduce the number of items provided by the ItemsSource to just a few (I'm using a readonly ObservableCollection as opposed to swapping out the ItemsSource entirely), the memory that seems to have been used by the previous set of list view items is not freed up.

If, then, I once again re-populate the items source with many items, new memory is allocated for the new items. This means that switching back and forth between the "few items" and "many items" states causes massive memory usage, often resulting in slowness, unresponsiveness, or crashing.

Is this expected/default behaviour for a ListView, and is it possible to change it such that the memory allocated to the list view item is freed up after its relevant entry is no longer in the ItemsSource?


Viewing all articles
Browse latest Browse all 611

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>