Connecting Tech Pros Worldwide Forums | Help | Site Map

how to destroy array

Sarfraz Hooda
Guest
 
Posts: n/a
#1: Nov 16 '05
Hi,

I have created an array of Objects in a collection. I was wondering is there
a way to destroy the array to free up the space in the memory ? or they are
automatically destroyed and garbagge collected by .Net framework?

Sarfraz



Jon Skeet [C# MVP]
Guest
 
Posts: n/a
#2: Nov 16 '05

re: how to destroy array


Sarfraz Hooda <shooda@iqueri.com> wrote:[color=blue]
> I have created an array of Objects in a collection. I was wondering is there
> a way to destroy the array to free up the space in the memory ? or they are
> automatically destroyed and garbagge collected by .Net framework?[/color]

When the array is no longer referenced (or is only referenced by things
eligible for garbage collection) it will become eligible for garbage
collection.

The references inside the array will become eligible for garbage
collection when the array does if and only if there are no other
references to them (which aren't themselves eligible for garbage
collection).

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Guest
 
Posts: n/a
#3: Nov 16 '05

re: how to destroy array


In addition, if you remove the items from the array using Remove(),
RemoveAt(), or Clear(), then the items are eligeable for garbage collection
as well. But again, this applies, if and only if, there are no other
references to the items.

Pete

"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.1b256aecaa01f5c498aa99@msnews.microsoft.c om...[color=blue]
> Sarfraz Hooda <shooda@iqueri.com> wrote:[color=green]
> > I have created an array of Objects in a collection. I was wondering is[/color][/color]
there[color=blue][color=green]
> > a way to destroy the array to free up the space in the memory ? or they[/color][/color]
are[color=blue][color=green]
> > automatically destroyed and garbagge collected by .Net framework?[/color]
>
> When the array is no longer referenced (or is only referenced by things
> eligible for garbage collection) it will become eligible for garbage
> collection.
>
> The references inside the array will become eligible for garbage
> collection when the array does if and only if there are no other
> references to them (which aren't themselves eligible for garbage
> collection).
>
> --
> Jon Skeet - <skeet@pobox.com>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too[/color]


Closed Thread


Similar C# / C Sharp bytes