-
Notifications
You must be signed in to change notification settings - Fork 656
Closed
Milestone
Description
Hi,
I am using gui::CDisplayWindow3D and opengl::CTexturedPlane for visualizing maps(colour maps not just gray).
I observed that there was memory leak in opengl::CTexturedPlane::assignImage .
If the below program run for 1000 loops (x =1000), it will fill the 16gb ram and the system hangs.
I have attached the program with cmake, so that you can build and verify the issue easily. Just run the program and observe the memory using htop.
Is it the correct way of using CImage with CTexturedPlane.
Thanks.
#include <iostream>
#include <mrpt/img/CImage.h>
#include <mrpt/opengl/CTexturedPlane.h>
#include <mrpt/gui/CDisplayWindow3D.h>
using namespace mrpt;
using namespace mrpt::img;
using namespace mrpt::gui;
using namespace mrpt::opengl;
int main()
{
long x = 0;
CDisplayWindow3D *window3D = new CDisplayWindow3D();
window3D->setWindowTitle("Visualization");
window3D->resize(800, 600);
opengl::CTexturedPlane::Ptr objs = opengl::CTexturedPlane::Create();
objs->setName("map");
objs->setPlaneCorners(0, 0, 0, 0);
opengl::COpenGLScene::Ptr &ptrScene = window3D->get3DSceneAndLock();
ptrScene->insert(objs);
window3D->unlockAccess3DScene();
window3D->forceRepaint();
while (x< 500)
{
//mrpt::img::CImage::Ptr imgColor = std::make_shared<mrpt::img::CImage>(1600, 1600, mrpt::img::TImageChannels::CH_RGB);
//mrpt::img::CImage::Ptr imgTrans = std::make_shared<mrpt::img::CImage>(1600, 1600, mrpt::img::TImageChannels::CH_GRAY);
mrpt::img::CImage imgColor(1600, 1600, mrpt::img::TImageChannels::CH_RGB);
mrpt::img::CImage imgTrans(1600, 1600, mrpt::img::TImageChannels::CH_GRAY);
for (uint32_t j = 0; j < 1600; j++) {
for (uint32_t i = 0; i < 1600; i++) {
//imgTrans->setPixel(i, j, img::TColor::red());
//imgColor->setPixel(i, j, img::TColor::green());
imgColor.setPixel(i, j, img::TColor::red());
imgTrans.setPixel(i, j, img::TColor::red());
}
}
{
opengl::COpenGLScene::Ptr &ptrScene = window3D->get3DSceneAndLock();
opengl::CTexturedPlane::Ptr ptrPlane = std::dynamic_pointer_cast<opengl::CTexturedPlane>(ptrScene->getByName("map"));
ptrPlane->setPlaneCorners(0, 0, 0, 0);
ptrPlane->setPlaneCorners(0, 0, 1599, 1599);
//ptrPlane->assignImage(*imgColor, *imgTrans);
ptrPlane->assignImage(imgColor, imgTrans); // causing memory leak
ptrPlane->notifyChange();
window3D->unlockAccess3DScene();
window3D->forceRepaint();
}
std::cout << "x = " << ++x <<std::endl;
}
if(window3D) delete window3D;
return 0;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels