Home Forums WPF controls Xceed DataGrid for WPF Help! Extreme memory usage and extremely poor performance

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26643 |

    Hello,

    I am hoping that somebody can help me with this. My company recently purchased Xceed DataGrid for WPF. We got off to a pretty good start but we have begun to notice that the datagrid uses extreme amounts of memory and is very slow with even modestly sized recordsets. For example, my application uses about 25 mb of memory with an empty Xceed datagrid. As soon as I populate the grid with a modest dataset (38 columns x 1141 rows) the memory usage of my application immidiately jumps to about 55mb. As I attempt to scroll down through the records the memory usage of my application fluctuates wildly and begins to grow as I page farther down into the recordset. While I am doing this the memory usage of my application can grow to as much as 280mb(!!!). Besides the memory usage performance is extremely slow … it is quite painful to try to scroll down through the recordset.

    Based on some advice that my co-worker found in this forum I tried setting the “maxwidth” and “maxheight” properties of the grid in which my datagrid sits. I also tried setting these properties on the datagrid control itself. I even tried placing the grid inside a stackpanel and setting these properties. None of this seemed to help.

    Here is the XAML that defines my datagrid:

    <xcdg:DataGridControl Name=”DataGrid” Margin=”0,180,0,30″ MaxWidth=”1898″ MaxHeight=”952″ ReadOnly=”True” IsTextSearchEnabled=”False” SelectionMode=”Single” NavigationBehavior=”RowOnly” ItemScrollingBehavior=”Deferred”>
    <xcdg:DataGridControl.View>
    <xcdg:TableView HorizontalGridLineThickness=”1″ VerticalGridLineThickness=”1″ ShowRowSelectorPane=”False” ShowFixedColumnSplitter=”False”></xcdg:TableView>
    </xcdg:DataGridControl.View>
    </xcdg:DataGridControl>

    Here is the C# that populates my datagrid:

    DataTable QueryResult = <proprietary call that returns a DataTable based on some inputs>;
    DataGrid.ItemsSource = new DataGridCollectionView(QueryResult.AsDataView());

    Here are the details of my development environment:

    Dell Inspiron E1705 laptop
    Intel T7200 Core 2 Duo @ 2 ghz
    2GB DDR2 @ 667mhz
    Windows Vista Ultimate SP1 (with all of the latest updates)
    Visual Studio 2008 Professional
    Xceed DataGrid for WPF v2.0.8127.13040

    For comparison, I built a similar form that uses the standard Windows Forms datagrid and uses all the same code to populate the grid … and it uses almost no more memory when the grid goes from empty to being populated with the same 38×1141 dataset I mentioned above. Memory usage stays steady at 25mb – 27mb, even when I scroll to the bottom of the dataset and back. Furthermore, scrolling is fast and smooth – I can scroll the bottom and back to the top in one easy smooth fast drag motion.

    Please help us out. If we can’t fix this then we won’t be able to use this product.

    Also, I wanted to mention that the forums are not very useful because the Search feature does not appear to work at all, and the paging is also broken. You can hit Prev and Next, but you can’t click any page numbers.

    Thanks in advance,

    Steve

    Imported from legacy forums. Posted by Stephen (had 2806 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Steve,

    A quick reply to give you an idea of what I have found since we have been using the DataGrid since its launch last year.

    The memory usage that you have is typically what I have seen. It is caused by the Virtualisation process which I is only effective on rows (ie columns are not virtualised). Hence memory usage does grow quite badly with columns.

    Depending how you are measuring the memory usage, if you force a garbage collection you shoudl see soem of teh memory is reclaimed. certainly it is what I see if I try to use a large number of rows.

    Scrolling – you are using the Deferred scrolling behaviour which does mean that as you page through the rows (or scroll) they are created on the fly. hence scrolling performance is what you see. Using Immediate gives instant scrolling (as forms) but initial load (and memory usage) is poor.

    The back to back tests that I have done using a simple test app do show that Forms is quicker and smaller, but the WPF DataGrid gives more scope for styling and we are hoping a longer life for this particular module.

    Hope that this helps in someway.

    Imported from legacy forums. Posted by Derek (had 619 views)

    Odi [Xceed]
    Spectator
    Post count: 426

    Hi Steve,

    >>We got off to a pretty good start but we have begun to notice that the datagrid uses extreme amounts of memory and is very slow with even modestly sized recordsets.

    Extreme memory use: there was a recent article about this effect in WPF, but after searching for it for quite a while yesterday, I couldn’t find it again to point you to it. The article was about WPF memory use and it boiled down to saying that a WPF app with a lot of visual elements may appear at times (such as when scrolling) to “need” a lot of memory, but it does so mainly when the garbage collector sees no pressure to free up memory. That might be what you are observing. Also, I don’t know if you are using Task Manager to check memory, but in other discussions I’ve seen, it appears not to be a reliable way to measure memory use.

    >>For example, my application uses about 25 mb of memory with an empty Xceed datagrid. As soon as I populate the grid with a modest dataset (38 columns x 1141 rows) the memory usage of my application immidiately jumps to about 55mb. As I attempt to scroll down through the records the memory usage of my application fluctuates wildly and begins to grow as I page farther down into the recordset. While I am doing this the memory usage of my application can grow to as much as 280mb(!!!).

    The scrolling scenario is a particularly good example of a situation in which garbage collection is taking it’s time to free up the memory. However, once you stop scrolling, memory use should go down as the system gets around to do the garbage collecting. Also, if other applications are using up memory, or there isn’t 280mb free for example, then the application won’t grab 280mb, but just what’s available.

    >>Besides the memory usage performance is extremely slow … it is quite painful to try to scroll down through the recordset.

    Have you tried the Live Explorer application? Does it perform well on your system? It doesn’t use very large recordsets, but it may be a useful tool to see if the slowness you are experiencing may possibly be a side effect of how you are using the grid. What you can do in your own application, as a test, is to reduce the number of columns to about the same as in the Live Explorer “Solid Foundation” sample (10-15) and go down to 100 rows, then see if it matches the Live Explorer’s performance.

    I think you may already be working with technical support on this, with no success yet. I guess you are probably aware that our development team’s first priority for v2.1 (the next release) is to implement a variety of techniques (some reported to us by Microsoft) that will improve the grid’s current performance.

    >>For comparison, I built a similar form that uses the standard Windows Forms datagrid and uses all the same code to populate the grid … and it uses almost no more memory when the grid goes from empty to being populated with the same 38×1141 dataset I mentioned above. Memory usage stays steady at 25mb – 27mb, even when I scroll to the bottom of the dataset and back. Furthermore, scrolling is fast and smooth – I can scroll the bottom and back to the top in one easy smooth fast drag motion.

    I should probably let one of the devs answer, but here’s my (not very technical) explanation of all this: With all the templating flexibility and styling power of WPF, it is a challenge to achieve Windows Forms-like performance, but probably not insurmountable, it just needs a lot of work. The memory behavior you’ve spotted probably stems from WPF’s retained-mode graphics system. That means that all those visual elements (cell contents, etc.) that scroll out of view have to be freed, otherwise WPF keeps them all in memory, and those visual elements have a big memory footprint. But freeing them doesn’t mean the memory is freed — the garbage collector may take its time to do that if there’s no immediate lack of memory. With Windows Forms, it doesn’t work that way. A row rendered to the screen becomes pixels, which just get overwritten by new pixels when scrolling. There’s far less memory activity going on.

    In WPF, new rows and their cells and contents appearing on the screen have to be generated on the fly, otherwise, we’d really be in trouble with performance and memory use. So we use UI vitrualization to help out. With new techniques recently suggested by Microsoft, such as template recycling, as well as lots of profiling work and optimizations, we should be able to do well, yet still retain all the flexibility and power of WPF in the DataGrid.

    >>Please help us out. If we can’t fix this then we won’t be able to use this product.

    The speed issues should be much improved in the next release, but as far as the memory fluctuations go, they may not completely dissapear, though I don’t have that information yet.

    >>Also, I wanted to mention that the forums are not very useful because the Search feature does not appear to work at all, and the paging is also broken. You can hit Prev and Next, but you can’t click any page numbers.

    Our new forums are almost ready, they should be going online within the next few weeks. That will take care of the broken search and paging features (though there is a workaround at the moment for the search, the FAQ mentions it, here’s the link: http://forums.xceed.com/forums/Search/default.aspx). Using that search and looking for performance brings up this thread too, which has some of the information I just wrote about: http://forums.xceed.com/Forums/ShowPost.aspx?PostID=11889

    Imported from legacy forums. Posted by Odi [Xceed] (had 4194 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.