TextBox内存消耗

7 浏览
0 Comments

TextBox内存消耗

我有一个UserControl,它是一个包含许多TextBox和TextBlock控件的项目列表。我尝试禁用撤消步骤,但即使在列表中添加了10个项目,内存消耗也非常高。我尝试运行内存分析工具,发现TextBox是最大的内存消耗者,约为50MB。

我的XAML如下所示:

...

SelectedItem="{Binding MyViewModel.SelectedRawMessageItem, Mode=OneWayToSource}" SelectionMode="Single" Background="OldLace"/>

我需要一些帮助来减少列表项的内存占用。

函数名称 总CPU (%) 自身CPU (%) 总CPU (ms) 自身CPU (ms) 模块

Gazelle.exe (PID: 8516) 100.00 % 0.00 % 29761 0 Gazelle.exe

[External Code] 99.80 % 23.01 % 29701 6849 50 modules

Gazelle.App::Main 0.19 % 0.00 % 58 0 Gazelle.exe

Gazelle.MainWindow::InitializeComponent 0.01 % 0.00 % 2 0 Gazelle.exe

对象类型 数量 大小(字节) 包含大小(字节) 模块

ListItem 10,464 251,136 573,839,736 PresentationCore.dll

TextBox 10,008 18,376,324 278,265,656 PresentationFramework.dll

List 25,098 23,258,200 185,202,668 mscorlib.dll

TextEditor 10,008 2,175,548 158,375,060 PresentationFramework.dll

Grid 12,624 12,400,172 151,944,940 PresentationFramework.dll

ListBoxItem 1,668 1,013,444 128,034,940 PresentationFramework.dll

TemplateNameScope 25,098 803,136 121,480,864 PresentationFramework.dll

ScrollViewer 10,015 10,694,204 81,834,452 PresentationFramework.dll

ContentPresenter 3,387 2,420,780 28,512,660 PresentationFramework.dll

EventHandler 233,861 10,732,196 25,202,352 mscorlib.dll

BindingExpression 65,292 24,139,292 24,189,152 PresentationFramework.dll

Border 13,419 11,634,248 18,898,436 PresentationFramework.dll

TextBoxView 10,008 11,549,424 18,597,828 PresentationFramework.dll

HybridDictionary 52,843 7,811,596 18,090,272 System.dll

ModifiedValue 192,048 4,803,732 16,476,568 WindowsBase.dll

ScrollBar 20,022 15,381,092 16,358,688 PresentationFramework.dll

ScrollContentPresenter 10,011 10,158,248 14,169,188 PresentationFramework.dll

[更新]

在XAML中添加这个可以使应用程序更加响应:

UndoLimit="0" AcceptsReturn="False" IsUndoEnabled="False"

现在我在思考还能从哪里获得更多的提升。

0