Subject: CGAL users discussion list
List archive
- From: MartinS <>
- To:
- Subject: [cgal-discuss] AABB_tree destructor memory leak
- Date: Tue, 28 May 2013 23:55:49 -0700 (PDT)
Hello guys,
there might be a memory leak in the AABB_tree destructor or, to be precise,
in the clear() method called from the destructor. I hit it by repeatedly
creating and destroying a tree using the Matlab external function interface
(MEX), which after a while gave me std::bad_alloc due to exhausted memory.
The clear() method in the original include/CGAL/AABB_tree.h (line 144+) is
m_primitives.clear();
clear_nodes();
clear_search_tree();
with the clear_nodes() being
if(size() > 1) {
delete [] m_p_root_node;
}
m_p_root_node = NULL;
As size() is a short for m_primitives.size() and m_primitives is cleared
before clear_nodes(), the if clause will fail to delete m_p_root_node and
thus leak memory.
Simply replacing the condition with
if(m_p_root_node) { ...
fixes the issue for me, but I am not familiar enough with the library to
fully understand why size() has been used in the first place. Maybe someone
more experienced can comment on this.
Thank you!
Btw. my CGAL version is 4.2 (Linux, installed from source)
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/AABB-tree-destructor-memory-leak-tp4657615.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] AABB_tree destructor memory leak, MartinS, 05/29/2013
Archive powered by MHonArc 2.6.18.