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
610
Memory issue when calling Row.RefreshSortPosition
posted

I have an ultragrid who's DataSource property is set to a BindingList. I'm using MVP in such a way that binding to models is the only way of communication between the view and presenter.

My app usually uses about 45-60MB of RAM. When stress testing by pulling back 50,000 rows from a database and adding them to the BindingList (one at a time since there is no AddRange on a BindingList), it causes the memory usage to fly up to 600MB - 1GB+ within a matter of seconds and then crashes with a System.OutOfMemory exception.

I thought it was due to the fact that each row has a image depending upon a value on that row. I changed all such usage of .Appearance to reuse Appearance objects I added to the Appearances collection when creating the grid, but the problem persists. I also changed to using GetCellValue instead of referencing cells.

I finally tracked it down to the fact that I call e.Row.RefreshSortPosition in InitializeRow. When I uncomment this line it only uses about 288MB of RAM. Higher than I'd like, but understandable for the ridiculous amount of data it's showing. (Ideally we need to get the user to filter better when pulling the data, but I wanted to test this scenario anyway...)

I do have columns added to the .SortedColumns to sort by, but (I may be mistaken) it seemed like rows added after the initial load (we push updates out to the client every so often) would not end up in the correct position. So I make that call to ensure that when I call BindingList.Add(item), it ends up in the right spot.

Any thoughts on why this may be happening?
(I can try to create a minimal solution to re-create the issue, but didn't want to do it, if it there was a simple "just do this instead" kind of answer. I'm using v10.3.)

Parents Reply Children
No Data