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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hello, mastiSoft!
why you cannot use?

Open in new window

Usually you can use

Open in new window

to clear array.
Chinmay PatelChief Technical NinjaCommented:
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?

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.