Click here to Skip to main content
12,954,601 members (55,521 online)

Welcome to the Lounge

   

For discussing anything related to a software developer's life. Technical discussions are encouraged, but click here to ask your programming questions.

The Lounge is rated PG. If you're about to post something you wouldn't want your kid sister to read then don't post it. No flame wars, no abusive conduct, no programming questions and please don't post ads.
 
GeneralRe: Automated way of checking if all instances of a type have been properly disposed of Pin
Vikram A Punathambekar19-Jan-09 16:06
memberVikram A Punathambekar19-Jan-09 16:06 
GeneralRe: Automated way of checking if all instances of a type have been properly disposed of Pin
Adar Wesley21-Jan-09 11:58
memberAdar Wesley21-Jan-09 11:58 
AnswerRe: Automated way of checking if all instances of a type have been properly disposed of Pin
John C19-Jan-09 9:44
memberJohn C19-Jan-09 9:44 
AnswerRe: Automated way of checking if all instances of a type have been properly disposed of Pin
Chris Maunder19-Jan-09 11:55
adminChris Maunder19-Jan-09 11:55 
GeneralRe: Automated way of checking if all instances of a type have been properly disposed of Pin
Vikram A Punathambekar19-Jan-09 16:04
memberVikram A Punathambekar19-Jan-09 16:04 
AnswerRe: Automated way of checking if all instances of a type have been properly disposed of Pin
Ennis Ray Lynch, Jr.19-Jan-09 16:02
memberEnnis Ray Lynch, Jr.19-Jan-09 16:02 
JokeRe: Automated way of checking if all instances of a type have been properly disposed of Pin
PIEBALDconsult20-Jan-09 8:50
memberPIEBALDconsult20-Jan-09 8:50 
AnswerRe: Automated way of checking if all instances of a type have been properly disposed of Pin
S. Senthil Kumar19-Jan-09 22:11
memberS. Senthil Kumar19-Jan-09 22:11 
I ran into a similar problem a while back, but we owned the code for the type (you could always disassemble/assemble).

My solution was to store the stack trace of the constructor of every instance of that type as a member in that type, and then in the finalizer, log the stack trace. I also ran a timer in the background that periodically called GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect();. That way, the finalizer would run for all instances that did not get disposed, and I would be able to see where those instances got created.

I would then run the application and try to exercise all paths in the code that deal with that type. I would then go through the log and fix code that was not disposing instances.

The trick is to make sure that all code paths that involve that type are exercised, and that's what makes this non-deterministic. A tool like NCover would probably help track code coverage.

You just gave me an idea - it would be nice to have a tool automate the first part (track instances and report where they are created in code). Now I know what I'll be doing over the Republic Day weekend Smile | :)

Hope this helps.

Regards
Senthil [MVP - Visual C#]
_____________________________
My Home Page |My Blog | My Articles | My Flickr | WinMacro

GeneralRe: Automated way of checking if all instances of a type have been properly disposed of Pin
Vikram A Punathambekar20-Jan-09 6:04
memberVikram A Punathambekar20-Jan-09 6:04 
GeneralRe: Automated way of checking if all instances of a type have been properly disposed of Pin
S. Senthil Kumar29-Jan-09 7:53
memberS. Senthil Kumar29-Jan-09 7:53 
GeneralRe: Automated way of checking if all instances of a type have been properly disposed of Pin
Vikram A Punathambekar30-Jan-09 5:43
memberVikram A Punathambekar30-Jan-09 5:43 
GeneralRe: Automated way of checking if all instances of a type have been properly disposed of Pin
Nishant Sivakumar21-Jul-09 1:43
sitebuilderNishant Sivakumar21-Jul-09 1:43 
GeneralRe: Automated way of checking if all instances of a type have been properly disposed of Pin
Vikram A Punathambekar21-Jul-09 6:09
memberVikram A Punathambekar21-Jul-09 6:09 
GeneralAny xml, xslt and xpath specialist ? Pin
AndyInUK19-Jan-09 5:34
memberAndyInUK19-Jan-09 5:34 
GeneralRe: Any xml, xslt and xpath specialist ? Pin
leppie19-Jan-09 5:51
mvpleppie19-Jan-09 5:51 
GeneralRe: Any xml, xslt and xpath specialist ? Pin
AndyInUK19-Jan-09 6:12
memberAndyInUK19-Jan-09 6:12 
GeneralRe: Any xml, xslt and xpath specialist ? Pin
leppie19-Jan-09 6:21
mvpleppie19-Jan-09 6:21 
RantI want my 4 hours back! Pin
leppie19-Jan-09 5:24
mvpleppie19-Jan-09 5:24 
GeneralRe: I want my 4 hours back! Pin
AndyInUK19-Jan-09 5:32
memberAndyInUK19-Jan-09 5:32 
GeneralRe: I want my 4 hours back! Pin
leppie19-Jan-09 5:46
mvpleppie19-Jan-09 5:46 
GeneralRe: I want my 4 hours back! Pin
wout de zeeuw19-Jan-09 7:21
memberwout de zeeuw19-Jan-09 7:21 
GeneralRe: I want my 4 hours back! Pin
leppie19-Jan-09 7:29
mvpleppie19-Jan-09 7:29 
GeneralComputer Stupidities Pin
Fahad Sadah19-Jan-09 5:18
memberFahad Sadah19-Jan-09 5:18 
GeneralRe: Computer Stupidities [modified] Pin
Fahad Sadah19-Jan-09 5:31
memberFahad Sadah19-Jan-09 5:31 
GeneralRe: Computer Stupidities Pin
John M. Drescher19-Jan-09 10:14
memberJohn M. Drescher19-Jan-09 10:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 28 May 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid