Page 1 of 1

if there is memory leaks when draw pointcloud frequently?

Posted: Tue May 23, 2017 7:09 am
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();
		

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

Posted: Tue May 23, 2017 6:18 pm
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.

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

Posted: Tue May 23, 2017 6:19 pm
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 ;)

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

Posted: Wed May 24, 2017 3:45 am
by Yeyan
ok,thanks!
i will check my code,may be the leak is from other code!