Array problem

Dear everyone,

In C++, when we allocated memory for array, we'd better to use delete operator to deallocate and free memory space. That's good.

How could I do that in C# How do I prevent memory leak by deallocating the memory allocated to array Thank you.

Regards,
David



Answer this question

Array problem

  • KingyNL

    AS has been said, the new operator is analagous to a non-pointer in C++. There is no delete operator in C#. However, if an object has a Dispose method, you should call it when you discard it, this cleans up resources faster than waiting for GC to do it.



  • sateesh

    hi,

    i don't think you need to do that , it will happen automaticly when GC runs , if your array went out of scope it will be removed,

    this article about (GC) Garbage Collector

    http://msdn.microsoft.com/library/default.asp url=/msdnmag/issues/1200/GCI2/TOC.ASP

    hope this helps



  • Array problem