473,607 Members | 2,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reference count?

I'm wondering if a tool exists that will integrate with the VS 2005
debugger, such that when I set a breakpoint I can inspect a reference and
see how many other references exist to that object. I'm sure there is an
internal reference count somewhere but have no idea how to inspect it.


May 4 '06 #1
7 2433
Hi Fred,

I am not sure if such reference count exists for managed object as it did
exist for COM objects. Reference count is not needed for garbage collection;
instead, there is a list of allocated objects and the garbage collector
knows the object roots of your app and traverses them and its referenced
objects; when finished, the objects in the list that have not been reached
are considered dead and its memory subject to be reclaimed.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com

"Fred Hedges" <do******@spamm uch.com> escribió en el mensaje
news:e3******** ***********@new s.demon.co.uk.. .
I'm wondering if a tool exists that will integrate with the VS 2005
debugger, such that when I set a breakpoint I can inspect a reference and
see how many other references exist to that object. I'm sure there is an
internal reference count somewhere but have no idea how to inspect it.

May 4 '06 #2
CMM
There is absolutely no reference counting in .NET AFAIK. None! Reference
counting is the source of lots of problems (circular references, leaks,
performance, etc).

When the garbage collector kicks in, it does all sorts of magic, suspends
everything for a brief second, counts references for "newly" created objects
(because "New" objects are typically only needed briefly) and destroys them,
and puts older objects (that have survived for a while) for cleanup later
on.... all designed to lessen the impact of the garbage collection
performance hit. There may be ways to tell where a "dead" object lays in the
line to oblivion... but I don't know how. Perhaps using some of .NET
Diagnostics counters, WMI, or stuff like that.

--
-C. Moya
www.cmoya.com
"Fred Hedges" <do******@spamm uch.com> wrote in message
news:e3******** ***********@new s.demon.co.uk.. .
I'm wondering if a tool exists that will integrate with the VS 2005
debugger, such that when I set a breakpoint I can inspect a reference and
see how many other references exist to that object. I'm sure there is an
internal reference count somewhere but have no idea how to inspect it.

May 4 '06 #3
Just to verify the thoughts of previous posters: There is no reference
count in .NET. The heap doesn't work that way in .NET.

Fred Hedges wrote:
I'm wondering if a tool exists that will integrate with the VS 2005
debugger, such that when I set a breakpoint I can inspect a reference and
see how many other references exist to that object. I'm sure there is an
internal reference count somewhere but have no idea how to inspect it.

May 4 '06 #4

Hmmmmm. I've firmly removed my COM hat now. Thanks for the responses.

So the Garbage Collector can walk the reference list and see if anything in
that list is pointing to something in it's set of allocated "things". Now,
I wonder.... is it possible to find out which things are pointing to a
particular interesting thing, if you see what I mean? ;).

"Göran Andersson" <gu***@guffa.co m> wrote in message
news:e7******** ******@TK2MSFTN GP03.phx.gbl...
Just to verify the thoughts of previous posters: There is no reference
count in .NET. The heap doesn't work that way in .NET.

Fred Hedges wrote:
I'm wondering if a tool exists that will integrate with the VS 2005
debugger, such that when I set a breakpoint I can inspect a reference and
see how many other references exist to that object. I'm sure there is an
internal reference count somewhere but have no idea how to inspect it.

May 4 '06 #5
Hi Fred,

See if there is something like that in the Compuware DevPartner product:

http://www.compuware.com/products/de...5_ENG_HTML.htm

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
"Fred Hedges" <do******@spamm uch.com> escribió en el mensaje
news:e3******** ***********@new s.demon.co.uk.. .

Hmmmmm. I've firmly removed my COM hat now. Thanks for the responses.

So the Garbage Collector can walk the reference list and see if anything
in that list is pointing to something in it's set of allocated "things".
Now, I wonder.... is it possible to find out which things are pointing to
a particular interesting thing, if you see what I mean? ;).


May 4 '06 #6
>So the Garbage Collector can walk the reference list and see if anything in
that list is pointing to something in it's set of allocated "things". Now,
I wonder.... is it possible to find out which things are pointing to a
particular interesting thing, if you see what I mean? ;).


I believe you can do that with the Sos.dll debugger extensions.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
May 4 '06 #7
Not feasible in any garbage collected system. Note I didn't say not
possible. Its simply that the overhead to do this would be so sever that
the system performance would noticibly suffer.

In VB 6 and COM, the system increments a counter in the object header every
time a reference is added to the object. Then the counter is decremented
whenever a reference is removed. When this counter reaches zero, the object
is removed, decrementing references in any objects it points to.

In .NET the system keeps track of memory roots. These are classically the
program stack and data segment. In .NET, there are additional roots such as
a stack and data segment for each thread in a program as well as other roots
that are maintained by the garbage collector itself. When the GC runs, it
starts with each root and sets a flag that uniquley identifies this GC run.
Any objects that aren't identified on this run are eligible for removal from
memory. After the mark pass, memory is compacted by the GC so that
available memory is consolidated at the end of the heap. Microsoft has a
rather extensive technet article on the .NET garbage collector, but this is
the fundamental description of all modern garbage collection systems. Thus,
there is no way to track the number of references to an object. All the
system needs is one reference and it stops looking.

Mike Ober.

"Fred Hedges" <do******@spamm uch.com> wrote in message
news:e3******** ***********@new s.demon.co.uk.. .
I'm wondering if a tool exists that will integrate with the VS 2005
debugger, such that when I set a breakpoint I can inspect a reference and
see how many other references exist to that object. I'm sure there is an
internal reference count somewhere but have no idea how to inspect it.



May 5 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1442
by: Richard Cavell | last post by:
Hi, The point of using const on a parameter to a function should be to let your compiler know that the parameter shouldn't be modified during your program. This allows you to keep your code safe and bug-free. Now, it also occurs to me that a const something-or-other could be passed as a reference (since it's guaranteed not to change) , or that the address of the object could be passed rather than the whole thing in the case of a...
1
3242
by: Tony Johansson | last post by:
Hello Experts! I reading a book called programming with design pattern revealed by Tomasz Muldner and here I read something that I don't understand completely. It says "A garbarage collector, such as the one used in Java, maintains a record of whether or not an object is currentlys being used. An unused object is tagged as garbage,
3
3163
by: Poewood | last post by:
Okay here are four classes for a pocket pc program: Input, fpositional, ComboBoxArray and TextBoxArray. The "input" class is the form. I use the fpositional class to handle most of the functions for the objects on the form, in addition the The objects are created in the fpositional class and affixed to the Input form through the fpositional constructor which takes the form as an argument. The ComboBox and TextBox Array classes hold the...
3
3225
by: BravesCharm | last post by:
BravesCharm Dec 7, 10:57 am show options Newsgroups: microsoft.public.dotnet.distributed_apps From: "BravesCharm" <mastrauc...@gmail.com> Date: 7 Dec 2004 10:57:40 -0800 Local: Tues, Dec 7 2004 10:57 am Subject: Have trouble with reference counts! Reply | Reply to Author | Forward | Print | Individual Message | Show original | Remove | Report Abuse
5
1426
by: raghu | last post by:
Hi All, I am a new user of Python and am having a bit of problem understanding the Reference counting and memory leakage issues. Requesting help from experienced users.... I wrote the following simple program.
1
2764
by: ank | last post by:
Hi, all. I've come to think of the idea of automatic initialization/deinitialization of non-local reference count pointer. I've made an assumption that the user of the pointer only read pointer after acquire the reference (increment the ref count) and when finished using it, the user will release the ref count.
2
2260
by: ank | last post by:
Hi, all. I've come to think of the idea of automatic initialization/deinitialization of non-local reference count pointer. I've made an assumption that the user of the pointer only read pointer after acquire the reference (increment the ref count) and when finished using it, the user will release the ref count.
1
2270
by: oec.deepak | last post by:
Hi Cn any one telll me what is Reference counting in C++.
11
3341
by: venkatagmail | last post by:
I have problem understanding pass by value and pass by reference and want to how how they are or appear in the memory: I had to get my basics right again. I create an array and try all possible ways of passing an array. In the following code, fun1(int a1) - same as fun1(int* a1) - where both are of the type passed by reference. Inside this function, another pointer a1 is created whose address &a1 is different from that of the passed...
275
12180
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
8049
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7985
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8463
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6803
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5997
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4013
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.