title: Does C# clean up C++ allocated memory?
body: <p>I have a hypothetical COM object with the following signature</p>
  
  <pre><code>void MemAlloc(ref double[] test, int membercount)
  </code></pre>
  
  <p>where the memory is allocated in C++ using new/malloc. Once this is in C#, using the RCW, how do I ensure that the memory is freed correctly? I would think it would be difficult for .NET to free, considering in C++ you need to know if it was allocated with new/malloc/mm_malloc before you can correctly free it. So, what is the appopriate way to cleanup my C++ allocated array? Thanks.</p>