release(dispose or clean) array

I need to convert short array to double one and I do this like this:
double[] doubleArray = Array.ConvertAll(shortArray, x => (double)x);
after doubleArray was used in function I have to release it (dispose or clean) in some way to avoid the memory leak.
For some reason I cannot do this on the way doubleArray.Clear();
Any ideas how can I do what I need?
Who is Participating?
käµfm³d 👽Commented:
Usually you can use


to clear array.
That does nothing to clear the array. All that does is clear out the reference that "doubleArray" points to--the data is still in memory. As Chinmay Patel mentioned, the garbage collector is responsible for cleaning up memory. Assigning null does nothing to invoke the garbage collector--garbage collection is non-deterministic.
Hello, mastiSoft!
why you cannot use?

Open in new window

Usually you can use

Open in new window

to clear array.
Chinmay PatelEnterprise ArchitectCommented:
Hi mastiSoft,

In C# all managed objects will be Garbage collected automatically. Have you observed any specific behavior exhibited by your app/code that leads you to believe there is a memory leak?

mastiSoftAuthor Commented:
it is correct, C# take a care about the GB but not always. In my case I could see the memory leak which I could eliminate by cleaning all variables after there use. On my computer it wasn't oblivious but when I tested software on the tablet then I could see how the
process slow down after some time.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.