title: IntPtr causing memory leak?
body: <p>This function is in a loop. When I run the program, the line with IntPtr is giving me memory problems, I've put delete[], but it still doesn't solve the memory problem, can anyone help please? thanks</p>
  
  <pre><code>void showImage(IplImage *img,System::Windows::Forms::PictureBox^ picturebox)
  {
  
  IntPtr ip(new unsigned char[img-&gt;widthStep*img-&gt;height]); // this line causing memory usage to keep going up very fast
  
  //memcpy(ip.ToPointer(),img-&gt;imageData,img-&gt;widthStep*img-&gt;height);
  
  //picturebox-&gt;Image = gcnew Bitmap(img-&gt;width,img-&gt;height, img-&gt;widthStep, System:rawing::Imaging::PixelFormat::Format24bppRgb, ip);
  
  delete[] ip;
  } 
  </code></pre>
  
  <p>This is C++\CLI</p>