title: Windows Phone 8.1 memory issue
body: <p>I have 8 large blocks of memory (28mb each). They are stored in unmanaged (native) code. And I want to dump them into files. But after I dump them, they are not released and I have 230mb busy memory, which make not available to continue running my app. Further thrown OutOfMemory.
  Here my dumping code:</p>
  
  <pre><code>//* Dump input images
  for (int i = 0; i &lt; frames.Length; i++)
  {
      StorageFile file = await localFolder.CreateFileAsync(
          string.Format("FRAME_{0}.yuv", i), 
  
      CreationCollisionOption.ReplaceExisting);
  
      using (var stream = await file.OpenStreamForWriteAsync())
      {
          byte[] image = SwapHeap.copyFromHeap(frames[i].ImagePtr, (int)frames[i].Width * (int)frames[i].Height * 3 / 2);
          await stream.WriteAsync(image, 0, image.Length);
          await stream.FlushAsync();
          image = null;
      }
  }
  ...
  System.GC.Collect();
  </code></pre>
  
  <p>And native code to get <code>byte[]</code> from <code>int</code> pointer:</p>
  
  <pre><code>Array&lt;uint8&gt;^ SwapHeap::copyFromHeap(const int ptr, int length) 
  {
      Array&lt;uint8&gt;^ res = ref new Array&lt;uint8&gt;(length);
      memcpy(res-&gt;Data, (byte*)ptr, length);
      return res;
  }
  </code></pre>
  
  <p>I free memory in native code using <code>free((byte*)ptr);</code> and it's ok. But I can't understand, why <code>byte</code> arrays are not released?</p>
  
  <p>P.S. I can dump data using native code, but I want to understand how GC works (msdn I've already read).</p>