wpf icon indicating copy to clipboard operation
wpf copied to clipboard

ComboBox Memory Leak with Large Data Sets

Open vsfeedback opened this issue 1 year ago • 2 comments

This issue has been moved from a ticket on Developer Community.


Hi,

I am having a issue that once you get over a set of data points in the combo box the memory usage runs up and stays up. My application is using the CB as a autocomplete textbox in WPF. Where the user selects a Manufacture as a Editable Combobox. That works fine since there is maybe 100 selections. But that querys a DB of parts for the Part number CB and i know the issue is in the CB since if you load the data model that it is binding too the memory doesnt rise that much and if you just type on the CB the memory doesnt rise but if you drop down it pulls like 300Mb of memory. For this application i dont need the drop down for say. but i dont follow why the memory has to fly up. Or that i can limit the drop down since there is not a native autocomplete text box that i know of. My main issue is that i like to have the drop down but i feel that if should limit the display and have a see more after say 1000 results. Since realistically is a user going to scroll. Probably not they will type the first dee then look. That is the other thing i noticed is it didnt seam to filter when typing. That may be because im using List in the data model.

Either way for data sake my app runs about 119Mb (Data loaded in model) without loading the CB Drop Down and if i click the drop down a few times i go to around 337Mb and about 5 sec lockup. So this is a issue i have to deal with one way or another.

This is WPF app on Net framework 4.8


Original Comments

Feedback Bot on 12/27/2023, 01:18 PM:

(private comment, text removed)

Robert Springer on 1/19/2024, 07:15 AM:

(private comment, text removed)

vsfeedback avatar Jul 16 '24 06:07 vsfeedback

Is this leak being observed in .NET Core as well?

singhashish-wpf avatar Jul 17 '24 05:07 singhashish-wpf

I did a quick test with dummy items in the dropdown... each 1 int, 2 strings. Important you MUST change the default ItemsPanel to allow virtualizing when working with large sets:

<ComboBox.ItemsPanel>
    <ItemsPanelTemplate>
        <VirtualizingStackPanel />
    </ItemsPanelTemplate>
</ComboBox.ItemsPanel>

Even with (in-memory) 1 million items in my itemssource and in my dropdown!, it's responsive and mem is stable with repeated dropdowns and scrolling. As you say: you'll be filtering. But I think the virtualzingpanel is what you are after. Give it a go.

xlsupport avatar Jul 28 '24 20:07 xlsupport