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
1878
Grid showing bitmap in column needs huge memory
posted

Hi,

during testing yesterday I got an OutOfMemoryException when trying to load about 20.000 rows into UltraGrid. Today I was investigating little bit more why this exception occurs, detected a rather interesting thing:

In the UltraGrid I'm using one column to display the status of the data that is displayed in the row using different images in .png-format. Each of this images has a size of around 1k. I now loaded 10.000 rows of data into the UltraGrid both with displaying the status image and without showing it, examined the memory usage of my application with Windows Task Manager:

  • 438,164MB - without showing the status image
  • 993,644MB - with showing the status image

I can imagine, that UltraGrid needs some overhead to display the image but that it suddenly needs more than double of memory is imho a little bit to much. The way I'm initializing the image is in the InitializeRow event handler of the UltraGrid by applying following code snippet:

private void OnInitializeRow(object sender, InitializeRowEventArgs e)

{

UltraGridCell statusCell= e.Row.Cells["StatusRow"];

statusCell.Appearance.ImageBackground = Resources.StatusImage1;

}

StatusImage1 is the .png-file.

Is there maybe a better and less memory consuming way to do that?

Regards,

Wolfgang

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi Wolfgang,

    qbupoew said:
    Is there maybe a better and less memory consuming way to do that?

    Absolutely. The way you are doing it here is terribly inefficient because you are forcing the grid to create an Appearance object for every cell.

    Check out the WinGrid Performance Guide and take a look at the last section entitled "Re-use Appearances".

Children