Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / December 2004

Tip: Looking for answers? Try searching our database.

Find all references

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kh - 31 Dec 2004 12:11 GMT
Hi. I am refactoring an application and I am in the process of adding cleanup
code. I am trying to dereference objects that are no longer required, but I
am finding that references are held in other parts of the application and the
object is consequently never collected.

Is there anyway to enumerate ALL references to a particular object instance
(either in code or interactively)? The GC can do it, so I am hoping I can too.

Thanks

kh
Jon Skeet [C# MVP] - 31 Dec 2004 12:43 GMT
> Hi. I am refactoring an application and I am in the process of adding cleanup
> code. I am trying to dereference objects that are no longer required, but I
[quoted text clipped - 3 lines]
> Is there anyway to enumerate ALL references to a particular object instance
> (either in code or interactively)? The GC can do it, so I am hoping I can too.

No - even the GC doesn't do it. It doesn't find all references to any
particular object, it just finds all objects which have live
references.

Profilers can do this, however. Unfortunately I don't have any
particular recommendations in terms of profilers.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

David Levine - 31 Dec 2004 17:35 GMT
As Jon pointed out there is no builtin mechanism for this; code inspection
might help here. One thing that can unintentionally cause references to
remain live are subscriptions to events that are never unsubscribed as the
event itself holds a reference to the subscriber. Other things to look at
are static fields that hold references to objects.

I'd run your app under a memory profiler and look at what's on the managed
heap. There are several free ones; I don't have links but it should be easy
enough to google some up.

> Hi. I am refactoring an application and I am in the process of adding
> cleanup
[quoted text clipped - 12 lines]
>
> kh

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.