|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Garbage Collector Reference CountingHi all,
I was wondering if there is a way to get the number of references an objects have (ie, other objects reference that object)? I know that .Net GC uses a different mechanism than the RefCount in C++ since .Net uses managed objects. I just need to know if there is any way possible to get this number. Any comments would be appreciated. Many of the debuggers / memory profilers will do it.
The ones that I use that have this feature are: - Windbg + Son of Strike. I often use the sosex extension as well, as I like it's commands quite a bit more than SOS's. - Scitech Memory Profiler will give you this. - I *think* the RedGate Memory profiler gives you this. -- Show quoteChris Mullins <mdo***@gmail.com> wrote in message news:6a035657-9014-4f90-a287-2edf63e5dfae@a39g2000pre.googlegroups.com... > Hi all, > > I was wondering if there is a way to get the number of references an > objects have (ie, other objects reference that object)? I know > that .Net GC uses a different mechanism than the RefCount in C++ > since .Net uses managed objects. I just need to know if there is any > way possible to get this number. > > Any comments would be appreciated. Unless you hook into the CLR, the answer is effectively no.
What do you want this information for? -- Show quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com <mdo***@gmail.com> wrote in message news:6a035657-9014-4f90-a287-2edf63e5dfae@a39g2000pre.googlegroups.com... > Hi all, > > I was wondering if there is a way to get the number of references an > objects have (ie, other objects reference that object)? I know > that .Net GC uses a different mechanism than the RefCount in C++ > since .Net uses managed objects. I just need to know if there is any > way possible to get this number. > > Any comments would be appreciated. I should elaborate, from within your program, you can't, but using
external tools, you can. Which are you trying to do, get it in your program, or outside of your program? -- Show quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in message news:una3%23PtMIHA.2000@TK2MSFTNGP05.phx.gbl... > Unless you hook into the CLR, the answer is effectively no. > > What do you want this information for? > > -- > - Nicholas Paldino [.NET/C# MVP] > - mvp@spam.guard.caspershouse.com > > <mdo***@gmail.com> wrote in message > news:6a035657-9014-4f90-a287-2edf63e5dfae@a39g2000pre.googlegroups.com... >> Hi all, >> >> I was wondering if there is a way to get the number of references an >> objects have (ie, other objects reference that object)? I know >> that .Net GC uses a different mechanism than the RefCount in C++ >> since .Net uses managed objects. I just need to know if there is any >> way possible to get this number. >> >> Any comments would be appreciated. > > Basically, we are building a WPF application and we are running
through performance issues, mostly memory issues. The problem resides where objects are not being collected by the GC even after the application have no use for it. I have tried nulling out the objects and calling GC.Collect() but it proved futile. One of the issues we found is with the event subscription bug where objects that have its event handlers subscribed are not being collected because the subscriber have a reference to it in some form. I tried removing the subscription using (-=) operator but it didn't seem to work. So I am trying to locate what is referencing the object so I can know how to remove it. Is there another way for this problem or am I going on the wrong path? |
|||||||||||||||||||||||