Answered by:
Exception of type 'System.OutOfMemoryException' was thrown.

Question
-
Hi,
I have a WPF application which is used to transfer loads of data from one Sql server to other Sql server. When i am using around 20000 records it is getting transferred successfully but when i wants to transfer more than 30000 records i am getting "Exception of type 'System.OutOfMemoryException' was thrown."
Please suggest what i need to do to fix this issue.
Friday, September 9, 2011 2:43 PM
Answers
-
Hi Syed,
I guess this seems to be an memory issue from ur description. It also depends upon ur record size. Say if ur single record size is 1KB and ur trying to transfer 20K - 30K records at the same time then it will occupy a lot of memory and u might get this exception.
If this is what ur trying then divide ur transfer operation into chunks of smaller size records.
Hope it helps!
Regards, Parth ShahFriday, September 9, 2011 3:23 PM -
I would recommend transferring the data in stages, instead of in a single, giant operation.
For example, if you always transfer data in blocks of 5000 records, and don't hold references to the records after you've transferred, the GC can kick in and release the memory as needed, preventing you from running out of memory.
Reed Copsey, Jr. - http://reedcopsey.com
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".Friday, September 9, 2011 4:35 PM
All replies
-
Hi Syed,
I guess this seems to be an memory issue from ur description. It also depends upon ur record size. Say if ur single record size is 1KB and ur trying to transfer 20K - 30K records at the same time then it will occupy a lot of memory and u might get this exception.
If this is what ur trying then divide ur transfer operation into chunks of smaller size records.
Hope it helps!
Regards, Parth ShahFriday, September 9, 2011 3:23 PM -
I would recommend transferring the data in stages, instead of in a single, giant operation.
For example, if you always transfer data in blocks of 5000 records, and don't hold references to the records after you've transferred, the GC can kick in and release the memory as needed, preventing you from running out of memory.
Reed Copsey, Jr. - http://reedcopsey.com
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".Friday, September 9, 2011 4:35 PM -
Not good to save more data in the memory once while you are transferring large data. As Reed said, you should transfer them in stages. A x86 process can use 2GB memory space, but the managed heap size is less then it. If you are using x64, it may use more space. But the space size is still limited by the physical space. A good design for transferring and space usage ca help our tool to improve its performance.
Sincerely,
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Monday, September 12, 2011 6:17 AM -
Hi Syed,
Any updates over this?
If ur query is resolved please close the post and mark it as an answer.
Regards, Parth ShahMonday, September 12, 2011 1:24 PM