Thursday, February 07, 2013 9:57 PM
In a C# 2008 application, I am using linq to sql statements that look like the following:
using (RPTDataContext rptData = new RPTDataContext())
var RPTupdate = (from a in rptData.Trackings
where a.Package_ID == pkgId
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?
Thursday, February 07, 2013 10:04 PM
The second case doesn't dispose of the TDataContext - this should eventually clean itself up, but it'd be better to wrap it in a using statement so you don't delay the collection/cleanup.
Reed Copsey, Jr. - http://reedcopsey.com
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
- Marked As Answer by wendy elizabeth Friday, February 08, 2013 6:04 AM