Perhaps someone could help with this issue. Please read the code behind:
void myapp::MainPage::Invalidate()
{
/* Get a new bitmap*/
m_pDIBitmap = m_pViewer->GetRenderData(FALSE);
m_pWriteableBitmap =ref new WriteableBitmap(m_pDIBitmap->GetWidth(), m_pDIBitmap->GetHeight());
IBuffer^ buffer = m_pWriteableBitmap->PixelBuffer;
/* Take the WinRT IBuffer interface and cast to an IUnknown */
IUnknown* pUnk = reinterpret_cast<IUnknown*>(buffer);
IBufferInternal* pBufferInternal = nullptr;
/* Get the undocumented interface for accessing the pixel buffer */
HRESULT hr = pUnk->QueryInterface(IID_IBufferInternal,
(void**)&pBufferInternal);
hr = pBufferInternal->GetBuffer(&m_pWriteableBitmapBuffer);
memcpy(m_pWriteableBitmapBuffer, m_pDIBitmap->GetBuffer(), m_pDIBitmap->GetHeight()*m_pDIBitmap->GetPitch());
/* Invalidates the writeable bitmap so it updates */
m_pWriteableBitmap->Invalidate();
/* Set the <Image/> source in the xaml to our WriteableBitmap */
Img->Source = m_pWriteableBitmap;
}
During run these codes, the memory consumption increments rapidly and the memory is never freed.
Does anyone has any solution or workaround for this problem? Do i miss anything?
Thanks in advance.