0

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.

sven
  • 11
  • 4
  • What has this to do with [tag:opencv]? – Emil Laine Mar 03 '15 at 15:44
  • the frames I render are opencv Mat types. I updated this in the post – sven Mar 03 '15 at 16:44
  • Which Ogre version and which render system? Additionally, if you think you found a bug, it might make sense to create a ticket on our tracker at http://jira.ogre3d.org – Philip Allgaier Mar 03 '15 at 19:37
  • Ogre 1.9and Direct3d 9 Rendering System. I would expect this to work since it is used in the sample of the Aruco library which I'm using http://sourceforge.net/projects/aruco/files/ogre-test/ – sven Mar 03 '15 at 22:44
  • Ok, the memory leak is solved. Apparently the problem was somewhere else... However updating the image of the texture is really slow using blitFromMemory(). If anyone has suggestions on how to speed this up please let me know. Thanks ! – sven Mar 04 '15 at 15:33

0 Answers0