N
N
Nikita2018-07-16 16:36:18
.NET
Nikita, 2018-07-16 16:36:18

How to reduce memory consumption in WPF DataGrid?

There is a DataGrid where data is uploaded at the request of the user. The amount of data is over 10,000 rows and approximately 12 columns.
As ItemSourse I use DataTable, which I get in the following form

var dataTable = new DataTable();
  dataTable.Load(con.ExecuteReader(select));

This DataTable contains more than 10,000 rows, it takes no more than 20 MB in memory, but when I try to display it all on the DataGrid, the memory captures reach more than 2 GB, which is unacceptable in my situation.
Are there any ways to reduce memory consumption when drawing data in a DataGrid?
Screen with memory
5b4c9e656165a573769365.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
eRKa, 2018-07-16
@Smiz001

Definitely need a pagination. No one takes out such volumes at once.
In extreme cases, loading as you scroll, with the removal of the upper part from the grid.
Even in width, it is not necessary to display everything, you can hide not the most critical data behind the "more" button and load it for viewing by clicking as additional data.

M
Michael, 2018-07-23
@pig_master

Still it is necessary to look at the DataGrid'a code. It looks like you turned off virtualization in it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question