Memory Leakage using datatables

Posted by Vix on Stack Overflow See other posts from Stack Overflow or by Vix
Published on 2010-05-26T06:58:14Z Indexed on 2010/05/26 7:01 UTC
Read the original article Hit count: 213

Hi, I have situation in which i'm compelled to retrieve 30,000 records each to 2 datatables.I need to do some manipulations and insert into records into the SQL server in Manipulate(dt1,dt2) function.I have to do this in 15 times as you can see in the for loop.Now I want to know what would be the effective way in terms of memory usage.I've used the first approach.Please suggest me the best approach.

(1)

for (int i = 0; i < 15; i++) { DataTable dt1 = GetInfo(i); DataTable dt2 = GetData(i); Manipulate(dt1,dt2); }

(OR)

(2)

        DataTable dt1 = new DataTable();
        DataTable dt2 = new DataTable();
        for (int i = 0; i < 15; i++)
        {
            dt1=null;
            dt2=null;
            dt1 = GetInfo();
            dt2 = GetData();
            Manipulate(dt1, dt2);
        }

Thanks, Vix.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET