weak referance
what is the advantage of weaf referace?
basically CLR allocate the memory from short/long weak referance table base
and the memory will be collected by the garbage by its rule when the object
is in no longer in reachable state.
but myconcern is in regular way the GC will collect the memory if the object
is no longer needed in weak referance if the GC didnt happen we can reclaim
that memory and we can use it.But MS describes that if we r going to deal
with larger chunck of memory weak referance will give the better performance
but i am not agree that.All the way its maintainingthe memory in the system
its not actually freeing it from original location.could any one clarify this.
thanks,
artral.
Date:Mon, 30 Jul 2007 02:54:02 -0700
Author:
|
Re: weak referance
Artralarasu wrote:
> what is the advantage of weaf referace?
> basically CLR allocate the memory from short/long weak referance table base
> and the memory will be collected by the garbage by its rule when the object
> is in no longer in reachable state.
>
> but myconcern is in regular way the GC will collect the memory if the object
> is no longer needed in weak referance if the GC didnt happen we can reclaim
> that memory and we can use it.But MS describes that if we r going to deal
> with larger chunck of memory weak referance will give the better performance
> but i am not agree that.All the way its maintainingthe memory in the system
> its not actually freeing it from original location.could any one clarify this.
>
> thanks,
> artral.
A weak reference is not considered by the garbage collector as an active
reference. That means that the object may be garbage collected if you
only have weak references to it.
If the heap runs out of unused memory, it will first do a garbage
collection before requesting more memory from the system. If you have
weakly referenced objects, they can be collected, and that will likely
be enough so that no extra memory needs to be allocated from the system
at that time.
--
Göran Andersson
_____
http://www.guffa.com
Date:Mon, 30 Jul 2007 12:55:21 +0200
Author:
|