This is a migrated thread and some comments may be shown as answers.

System Out of Memory..

1 Answer 239 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
FISCAL
Top achievements
Rank 1
FISCAL asked on 04 Apr 2011, 04:38 PM
Hi,

During our testing, when we try to export 41,847 records from grid to Excel containing 30 columns we started getting system out of memory exception. Could you please hint us what is wrong? To make it clear our server has just 2GB of memory but our understanding is export process shouldn't be grabbing whole memory.

Many thanks

MG

1 Answer, 1 is accepted

Sort by
0
Petko_I
Telerik team
answered on 07 Apr 2011, 05:33 PM
Hi Milan,

When OpenAccess executes a query the actual retrieval of results is split into chunks. There is a fetch size that determines the number of records that are read from the database in a single pass. With a query that returns a lot of records this means that the fetch size is not exceeded and not all 40 000 records will be retrieved at one time in memory. Iterating over the result data you will get  several reads from the database until the iteration is over. However, when you iterate over the result set subsequent reads are accumulated when you keep references to the objects that are iterated.
An out of memory exception may be caused when you operate with all the records from the grid. The way to avoid such an error would be to work with the data in chunks. For example, a paging for the grid and an option that exports data sequentially from all pages will achieve this. The goal is to try to reduce the objects kept in-memory at a time and let the garbage collection free unneeded memory. A LINQ query with Skip() and  Take() is ideal in such cases where having all the data in-memory is costly. Can you tell us a bit more regarding the scenario you are aiming at? Do you already have paging enabled for the grid, is it viable in your scenario and do the above mentioned suggestions apply? Also, what kind of grid control are you using?

We are looking forward to getting to the bottom of the issue.

All the best,
Petko_I
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
FISCAL
Top achievements
Rank 1
Answers by
Petko_I
Telerik team
Share this question
or