I'm rendering a camera stream to a texture in my Ogre scene using BlitFromMemory(). However, when I call this function it somehow internally saves the image and does not free it automatically the next frame because my program suddenly starts to use a lot of memory. When I comment this single line out (and do not update the texture every frame) the memory leak is gone...
I have no clue if this is a bug in ogre or if I should free some memory manually with this function...
Here is what I do:
m_PixelBox = Ogre::PixelBox(width, height, 1, Ogre::PF_R8G8B8, m_currentFrame.ptr<uchar>(0));
m_Texture = Ogre::TextureManager::getSingleton().createManual("CameraTexture",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,width,height,0,Ogre::PF_R8G8B8,Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
Every frame I do this: (newFrame and m_currentFrame are both opencv Mat types)
newFrame.copyTo(m_currentFrame);
m_Texture->getBuffer()->blitFromMemory(m_PixelBox);
It all works but it causes a big memory leak and I can only run my program for a brief moment since the frames are quite big.