Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
150
UltraGrid/DataTable memory usage
posted

Hi all,

This is something of a broad question, and I'd appreciate any experience or advice people might have.

I'm finding that the UltraGrid can sometimes consume a lot of memory. I'm loading data from raw text files (50 MB in total) and displaying the data as columns of doubles and strings in several grids. I've seen the memory usage of my program shoot up to approximately 500 MB. Memory profiling reveals that most of the data is string arrays and double arrays from the grid and its data structures (but mainly string arrays).

The grids are backed by DataTables that I generate myself.

So my question is, what would be some good advice for keeping the memory usage of the grid down?

A second question, which perhaps is outside of the scope of this forum, is what can be done to keep the memory usage of the System.Data.DataTable down. The single best thing I've found was to set the initial capacity of the table to reduce the amount of memory it allocates. Normally it seems to double the amount of rows allocated each time it runs out of memory, so setting the exact capacity from the start was a big help.

 Any advice/ideas would be appreciated.

 Many thanks,

Johan Nystrom 

 

 

 

Parents
No Data
Reply
  • 150
    posted

    Thanks for the responses.

     I've gone through my code to reduce the amount of Row and Cell objects that get created, and this did reduce memory usage somewhat.

     I think my main culprit is probably my use of DataTables and not the grid. So at some point I might review what kind of data containers I use. The problem is, I need to generate columns dynamically at run time, so I don't think I can simply use a BindingList with a hardcoded class. The reason I chose to use the DataTable in the first place was that it allows me to add columns as I please. But now it seems there's a lot of overhead associated with using it, in terms of both cpu and memory usage.

     Thanks again for the input, this has definitely given me more insight.

Children