Arrays and freeing memory

  • Thread starter Thread starter .:: MaStErDoN ::.
  • Start date Start date
M

.:: MaStErDoN ::.

Hi!
I'm working with arrays, saving on them information about files. All works
fine but the problem is that when i finish using them and i remove all the
information using:
for index = array.count to 0 step -1
array.remove(index);
next
i check the task manager and my program is still using 32 mb!!
Is there any way to free memory when i finish using the arrays??

Thanks!
 
Hi Andrés,

I assume you are using an ArrayList and RemoveAt(int index) as arrays are very different and do not have a remove method.

1: The objects removed from the list may be referenced elsewhere, in which case they won't be garbage collected until all references are ended.

2: The garbage collector will not clear the objects right away so there may be a time delay before they are destroyed. If you have a lot of memory it may decide that it's better that you have a fast program and delay clearing the objects until you end your program or memory runs low.

Happy coding!
Morten Wennevik [C# MVP]
 
Back
Top