Search:
Namespaces
Discussions
.NET v1.1
Feedback
Circular References
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngarchitecture' list
.
Mark Feinholz
Does anyone know if the GC takes care of cleaning up objects that have
circular references to eachother if those are the only references beng
held.
I have a typical object hierarchy structure, and the 1-to-1 child
objects as well as the 1-to-many child collection objects along with the
objects in those collections need a reference to their parent so they
can subscribe to eachothers events, etc
I would rather not have to code Dispose logic to remove the parent
reference as I understand this negatively affects GC performance.
Reply to this message...
Andy Smith
yes, it does.
the current GC doesn't use simple ref counting for this exact reason.
__
Andy Smith
Keyboard Jockey #3a7-2.78.1
-----Original Message-----
From: Mark Feinholz [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, June 26, 2002 8:40 PM
To: aspngarchitecture
Subject: [aspngarchitecture] Circular References
Does anyone know if the GC takes care of cleaning up objects that have circular references to eachother if those are the only references beng held.
I have a typical object hierarchy structure, and the 1-to-1 child objects as well as the 1-to-many child collection objects along with the objects in those collections need a reference to their parent so they can subscribe to eachothers events, etc
I would rather not have to code Dispose logic to remove the parent reference as I understand this negatively affects GC performance.
| [aspngarchitecture] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngarchitecture.asp
= JOIN/QUIT
|
http://www.asplists.com/search
= SEARCH Archives
Reply to this message...
Wolfgang Baeck
Circular ReferencesThey are being correctly dropped by the GC if that's the
only reference.
Wolfgang
-----Original Message-----
From: Mark Feinholz [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, June 26, 2002 8:40 PM
To: aspngarchitecture
Subject: [aspngarchitecture] Circular References
Does anyone know if the GC takes care of cleaning up objects that have
circular references to eachother if those are the only references beng held.
I have a typical object hierarchy structure, and the 1-to-1 child objects
as well as the 1-to-many child collection objects along with the objects in
those collections need a reference to their parent so they can subscribe to
eachothers events, etc
I would rather not have to code Dispose logic to remove the parent
reference as I understand this negatively affects GC performance.
| [aspngarchitecture] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngarchitecture.asp
= JOIN/QUIT
|
http://www.asplists.com/search
= SEARCH Archives
Reply to this message...
Minh Truong
From: "Mark Feinholz" <
Click here to reveal e-mail address
>
[Original message clipped]
Yes, circular reference detection is one of the thing emphasized about the
GC.
Reply to this message...
Chris Anderson
Basically GC collects objects that are not accessible from the running
application.
If those objects just happen to reference each other, that's immaterial
ie..circular references will get collected (as long as none of the
"participants" are referencable from the app)
Merak
-----Original Message-----
From: Mark Feinholz [mailto:
Click here to reveal e-mail address
]
Sent: 27 June 2002 03:40
To: aspngarchitecture
Subject: [aspngarchitecture] Circular References
Does anyone know if the GC takes care of cleaning up objects that have
circular references to eachother if those are the only references beng held.
I have a typical object hierarchy structure, and the 1-to-1 child objects as
well as the 1-to-many child collection objects along with the objects in
those collections need a reference to their parent so they can subscribe to
eachothers events, etc
I would rather not have to code Dispose logic to remove the parent reference
as I understand this negatively affects GC performance.
| [aspngarchitecture] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngarchitecture.asp
= JOIN/QUIT
|
http://www.asplists.com/search
= SEARCH Archives
Reply to this message...
Radim Hampel
I've read somewhere that yes, it does clean up these circular referenced
objects. But i don't know anything more about this subject, and i would
like to know the alghoritm that finds up these references.
Radim Hampel
ecommerce.cz, a. s.
=20
-----Original Message-----
From: Mark Feinholz [mailto:
Click here to reveal e-mail address
]=20
Sent: Thursday, June 27, 2002 4:40 AM
To: aspngarchitecture
Subject: [aspngarchitecture] Circular References
Does anyone know if the GC takes care of cleaning up objects that have
circular references to eachother if those are the only references beng
held.=20
I have a typical object hierarchy structure, and the 1-to-1 child
objects as well as the 1-to-many child collection objects along with the
objects in those collections need a reference to their parent so they
can subscribe to eachothers events, etc
I would rather not have to code Dispose logic to remove the parent
reference as I understand this negatively affects GC performance.
| [aspngarchitecture] member
Click here to reveal e-mail address
=3D YOUR ID
|
http://www.asplists.com/asplists/aspngarchitecture.asp
=3D JOIN/QUIT
|
http://www.asplists.com/search
=3D SEARCH Archives
Reply to this message...
Paul D. Murphy
In C# you can use the using keyword for an object that has a lot of
dependencies. Lets say you have a function that does some data
operations through utility method like ChangePassword(). If you are
using the 'using' keyword you can guarantee that all operations inside
of ChangePassword get treated as a group and all references are
destroyed when the block exits.
Public System.
Int32
ChangePassword(int userid, string old, string new)
{
using(System.Data.DataSet userDS =3D DBTier.GetUser(userid))
{
// change the password
}
return -1;
}
In this method no matter how complicated the references when the using
statement exits all references created during code block are destroyed.
Paul
Paul D. Murphy
Click here to reveal e-mail address
"Teamwork is a lot of people doing what I say."
-----Original Message-----
From: Radim Hampel [mailto:
Click here to reveal e-mail address
]=20
Sent: Thursday, June 27, 2002 9:54 AM
To: aspngarchitecture
Subject: [aspngarchitecture] RE: Circular References
I've read somewhere that yes, it does clean up these circular referenced
objects. But i don't know anything more about this subject, and i would
like to know the alghoritm that finds up these references.
Radim Hampel
ecommerce.cz, a. s.
=20
-----Original Message-----
From: Mark Feinholz [mailto:
Click here to reveal e-mail address
]=20
Sent: Thursday, June 27, 2002 4:40 AM
To: aspngarchitecture
Subject: [aspngarchitecture] Circular References
Does anyone know if the GC takes care of cleaning up objects that have
circular references to eachother if those are the only references beng
held.=20
I have a typical object hierarchy structure, and the 1-to-1 child
objects as well as the 1-to-many child collection objects along with the
objects in those collections need a reference to their parent so they
can subscribe to eachothers events, etc
I would rather not have to code Dispose logic to remove the parent
reference as I understand this negatively affects GC performance.
| [aspngarchitecture] member
Click here to reveal e-mail address
=3D YOUR ID
|
http://www.asplists.com/asplists/aspngarchitecture.asp
=3D JOIN/QUIT
|
http://www.asplists.com/search
=3D SEARCH Archives
| [aspngarchitecture] member
Click here to reveal e-mail address
=3D YOUR ID
|
http://www.asplists.com/asplists/aspngarchitecture.asp
=3D JOIN/QUIT
|
http://www.asplists.com/search
=3D SEARCH Archives
Reply to this message...
mail
All the talk about reference counting and GC, the problem is one of
doing clean code. The thing is that you should use methodology!!!! call
dispose for all of your object!!!!!!!! and write dispose for all your
objects!!!!!!!!!!!.
In the example you posted if you are using a person object when you
finished using it should should call "person.Dispose" when you write
person.dispose you call dispose in all of it references to other object
and set them to null, and you got it!!!!!!!!! person.Dispose will call
email.Dispose and email will clean it's reference to person and break
the circular reference. But that's doing your homeworks and many people
don like to
do it!!! jajajaja.
"Circular references" can be solved 99.999999999999 of the times with
design, as long as you have a hirarchy of references and that always
happens beacuse you allways start with a process. the GC is meant to
solve more complicated "Circular references" that should occur with
multiple threads and precesses. If you give it a moment youll realize
that.
Hey those who write out the make and article on this and name me!!!!!!
or tell me how can i make little articles like this and stuff
Alejandro G. Jack
Click here to reveal e-mail address
-----Original Message-----
From: "Radim Hampel" <
Click here to reveal e-mail address
>
To: "aspngarchitecture" <
Click here to reveal e-mail address
>
Date: Thu, 27 Jun 2002 15:53:38 +0200
Subject: [aspngarchitecture] RE: Circular References
[Original message clipped]
Reply to this message...
Chris Anderson
Correct me if I'm wrong, but circular references and the Dispose method have
nothing to do with each other
You can have circular references on objects that do not need disposing
It's true that if you have objects that expose a Dispose/Close method that
it is prudent to call it..but this is true regardless of whether circular
references exist
Merak
[Original message clipped]
Reply to this message...
Mark Feinholz
OK, OK, I'll design in Dispose methods - now go have a beer or somthin
:)
-----Original Message-----
From: mail [mailto:
Click here to reveal e-mail address
]
Sent: Thursday, June 27, 2002 9:30 AM
To: aspngarchitecture
Subject: [aspngarchitecture] RE: Circular References
All the talk about reference counting and GC, the problem is one of
doing clean code. The thing is that you should use methodology!!!! call
dispose for all of your object!!!!!!!! and write dispose for all your
objects!!!!!!!!!!!.
In the example you posted if you are using a person object when you
finished using it should should call "person.Dispose" when you write
person.dispose you call dispose in all of it references to other object
and set them to null, and you got it!!!!!!!!! person.Dispose will call
email.Dispose and email will clean it's reference to person and break
the circular reference. But that's doing your homeworks and many people
don like to
do it!!! jajajaja.
"Circular references" can be solved 99.999999999999 of the times with
design, as long as you have a hirarchy of references and that always
happens beacuse you allways start with a process. the GC is meant to
solve more complicated "Circular references" that should occur with
multiple threads and precesses. If you give it a moment youll realize
that.
Hey those who write out the make and article on this and name me!!!!!!
or tell me how can i make little articles like this and stuff
Alejandro G. Jack
Click here to reveal e-mail address
-----Original Message-----
From: "Radim Hampel" <
Click here to reveal e-mail address
>
To: "aspngarchitecture" <
Click here to reveal e-mail address
>
Date: Thu, 27 Jun 2002 15:53:38 +0200
Subject: [aspngarchitecture] RE: Circular References
[Original message clipped]
| [aspngarchitecture] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngarchitecture.asp
= JOIN/QUIT
|
http://www.asplists.com/search
= SEARCH Archives
Reply to this message...
Mark Feinholz
The point is, if you implement a Dispose method that takes care of
calling children Dispose methods and cleaning up its own references,
then you don't have to count on the GC to be smart enough to clean up
after you. A Dispose method is simply a standard method name that can
do whatever it needs to do to clean up an object before the client
application releases its reference.
Taking it a step further, I suppose I should implement iDisposable and
let the GC execute Dispose if I don't tell it that it doesn't have to.
Mark.
-----Original Message-----
From: Chris Anderson [mailto:
Click here to reveal e-mail address
]
Sent: Thursday, June 27, 2002 9:51 AM
To: aspngarchitecture
Subject: [aspngarchitecture] RE: Circular References
Correct me if I'm wrong, but circular references and the Dispose method
have
nothing to do with each other
You can have circular references on objects that do not need disposing
It's true that if you have objects that expose a Dispose/Close method
that
it is prudent to call it..but this is true regardless of whether
circular
references exist
Merak
[Original message clipped]
| [aspngarchitecture] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngarchitecture.asp
= JOIN/QUIT
|
http://www.asplists.com/search
= SEARCH Archives
Reply to this message...
Russ McClelland
VGhlIGFzc3VtcHRpb24gdGhhdCBHQyBhcmUgbWVhbnQgdG8gc29sdmUgbXV0bGktdGhyZWFkaW5n
IHByb2Nlc3NpbmcNCmlzc3VlcyBpcyBiYXNpY2FsbHkgYSBmbGF3ZWQgYXNzdW1wdGlvbi4gIFdo
aWxlIGl0cyB0cnVlIHRoYXQgdGhleSB3aWxsDQpzb2x2ZSB0aGF0IHBhcnRpY3VsYXIgY2FzZS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RoZSBjaXJjdWxhciByZWZlcmVuY2UuIEJ1dCB0aGF0J3MgZG9pbmcg
eW91ciBob21ld29ya3MgYW5kIG1hbnkNCnBlb3BsZQ0KCWRvbiBsaWtlIHRvDQoJZG8gaXQhISEg
amFqYWphamEuDQoJIkNpcmN1bGFyIHJlZmVyZW5jZXMiIGNhbiBiZSBzb2x2ZWQgOTkuOTk5OTk5
OTk5OTk5IG9mIHRoZSB0aW1lcw0Kd2l0aA0KCWRlc2lnbiwgYXMgbG9uZyBhcyB5b3UgaGF2ZSBh
IGhpcmFyY2h5IG9mIHJlZmVyZW5jZXMgYW5kIHRoYXQNCmFsd2F5cw0KCWhhcHBlbnMgYmVhY3Vz
ZSB5b3UgYWxsd2F5cyBzdGFydCB3aXRoIGEgcHJvY2Vzcy4gdGhlIEdDIGlzDQptZWFudCB0bw0K
CXNvbHZlIG1vcmUgY29tcGxpY2F0ZWQgIkNpcmN1bGFyIHJlZmVyZW5jZXMiIHRoYXQgc2hvdWxk
IG9jY3VyDQp3aXRoDQoJbXVsdGlwbGUgdGhyZWFkcyBhbmQgcHJlY2Vzc2VzLiBJZiB5b3UgZ2l2
ZSBpdCBhIG1vbWVudCB5b3VsbA0KcmVhbGl6ZQ0KCXRoYXQuDQoJSGV5IHRob3NlIHdobyB3cml0
ZSBvdXQgdGhlIG1ha2UgYW5kIGFydGljbGUgb24gdGhpcyBhbmQgbmFtZQ0KbWUhISEhISENCglv
ciB0ZWxsIG1lIGhvdyBjYW4gaSBtYWtlIGxpdHRsZSBhcnRpY2xlcyBsaWtlIHRoaXMgYW5kIHN0
dWZmDQoJDQoJICAgQWxlamFuZHJvIEcuIEphY2sNCgl3ZWJtYXN0ZXJAc291dGh3b3Jrcy5uZXQN
CgkNCg0K
Reply to this message...
mail
Maybe i was miss understood, what i meant is that you should consider GC
as a backdoor for memory leaks. I think a backdoor should be used less
than main doors!!! and your main door should be puting dispose code.
Also you should consider that the GC is lazzy and won't reclaim memory
if it' doesn't need to, with dispose you can "simulate" a deterministic
finalization. The idea is to leave the GC for complicated situations you
can't forsee not for the ones you can see like the circular references
between a parent object and his childs.
-----Original Message-----
From: "Russ McClelland" <
Click here to reveal e-mail address
>
To: "aspngarchitecture" <
Click here to reveal e-mail address
>
Date: Thu, 27 Jun 2002 17:21:32 -0500
Subject: [aspngarchitecture] RE: Circular References
[Original message clipped]
Reply to this message...
System.Data.DataSet
System.Int32
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com