dc

dc

  • NA
  • 629
  • 0

linq to sql question

Feb 7 2013 5:02 PM
In a C# 2008 application, I am using linq to sql statements that look like the following: 
     Case 1:              

        using (RPTDataContext rptData = new RPTDataContext())
                        {

                            var RPTupdate = (from a in rptData.Trackings
                                              where a.Package_ID == pkgId
                                              select a).SingleOrDefault();
                         }

       Case 2:
           TDataContext TData = new TDataContext();
         var TNumber = (from dw in cms_TData.people
                      where dw.Organization_Name.ToUpper().Trim() == strOrgnizationName.Trim()


I am asking that question since an application I am working on is having a memory leak. I am trying to
rule out the above statements as the reason for the memory leak.

My question is could either of this statements cause a memory leak, leave a database connection open,
keep the database object 'alive' in memory? If so, can you tell me what statement could cause that kind of
problem and how to write the code so the problem does not persist?

Answers (1)