if there is memory leaks when draw pointcloud frequently?

Any question about the main GUI application (frontend)
Post Reply
Yeyan
Posts: 7
Joined: Wed Jul 27, 2016 6:58 am

if there is memory leaks when draw pointcloud frequently?

Post by Yeyan »

Hi:
I write a octree to draw huge amount of point cloud(almost 5 billion points) myself.
when i draw pointcloud,i find the memory is growing. for test is there memory leaks , I write some test code like following:
when i remove all children ,i find there is about 40M memory leak , but then i move mouse in window several times, the memory is free. Or I comment out "activeWin->redraw()" in code ,there is no memory leak.
I check ccpointcloud's function removeChild or clear(),it seems like no problem. I don't know why, but this is so weird to me,because i need add child、remove child and redraw glwindow frequently!
Is qglwindow->draw() has memory leaks somewhere?the code versions is 2.8.1.

Code: Select all

	ccHObject* testDB = new ccHObject();
		addToDB(testDB);
		ccGLWindow* activeWin = getActiveGLWindow();
		if (testDB)
		{
			// test 20 times
			for (int i = 0; i<20; i++)
			{
				int nLen = 200000;
				// new pointcloud
				ccPointCloud* pcd = new ccPointCloud;
				if (!pcd->reserveThePointsTable(nLen))
					return;

				CCVector3 point;
				int offset(0);

				// create points
				for (int i = 0; i<nLen; i++)
				{
					point.x = qrand() % 2000;
					point.y = qrand() % 2000;
					point.z = qrand() % 2000;
					pcd->addPoint(point);
				}
				pcd->setDisplay_recursive(activeWin);
				testDB->addChild(pcd);
				activeWin->redraw();
				//activeWin->redraw();
			}
		}

		// remove
		testDB->removeAllChildren();
		activeWin->redraw();
		
daniel
Site Admin
Posts: 7711
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: if there is memory leaks when draw pointcloud frequently?

Post by daniel »

There's no memory leak I'm aware of, but you may have some strange memory management due to the use of VBOs (Vertex Buffer Objects). They are transferred asynchronously to the graphic card and this feature is handled by the graphic card driver. You could test this hypothesis by disabling the 'load clouds on GPU for faster display' option in the Display settings.
Daniel, CloudCompare admin
daniel
Site Admin
Posts: 7711
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: if there is memory leaks when draw pointcloud frequently?

Post by daniel »

And if you have a way to display 5 billion points smoothly, I'm sure a lot of people will be interested by this feature ;)
Daniel, CloudCompare admin
Yeyan
Posts: 7
Joined: Wed Jul 27, 2016 6:58 am

Re: if there is memory leaks when draw pointcloud frequently?

Post by Yeyan »

ok,thanks!
i will check my code,may be the leak is from other code!
Post Reply