I have a class to export invoice data to csv file. But when the invoice has 100 lines or more, we a getting the error below. I'm doing tests in my Test environment that just have 8GB ram memory and the Dynamics version is 4.0.

In the code I have some tables and in final of code I add table = null to leave memory, but is not working. I checked the Resouce Monitor and when the memory free is 0 show the error.

If the process finish, but we start again, the error will show because the free memory is almost 0.

How can I solve it? Thanks!

PS: The live environment have the same issue with 16GB ram memory.

Code example: