mirror of https://github.com/CGAL/cgal
Fix the memory leak in minkowski_sum_3
Gaussian_map allocates a Sphere_map on every construction and passes it off to its base class SM_decorator. The decorator has a shallow copy-constructor and doesn't clean up its resource. The best fix would be to use a shared_ptr for psm_ in SM_decorator, but that possibly breaks users and classes that actually account for the missing memory management. This is the worst of all possible fixes. We just clean up all pointers. The code now checks fine with gperftools and HEAPCHECK=strict
This commit is contained in:
parent
52684f2b1a
commit
3a0932f578
|
|
@ -220,6 +220,16 @@ bipartite_nary_union_sorted_combined(Nef_polyhedron& N0,
|
||||||
Ntmp.delegate(Convertor, true);
|
Ntmp.delegate(Convertor, true);
|
||||||
CGAL_assertion(Ntmp.is_valid());
|
CGAL_assertion(Ntmp.is_valid());
|
||||||
nary_union.add_polyhedron(Ntmp);
|
nary_union.add_polyhedron(Ntmp);
|
||||||
|
delete GcG.sphere_map();
|
||||||
|
}
|
||||||
|
|
||||||
|
// clean up the spherical_mapS
|
||||||
|
for(GM_iterator it = GM0.begin(); it != GM0.end(); ++it) {
|
||||||
|
delete it->first.sphere_map();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(GM_iterator it = GM1.begin(); it != GM1.end(); ++it) {
|
||||||
|
delete it->first.sphere_map();
|
||||||
}
|
}
|
||||||
|
|
||||||
return nary_union.get_union();
|
return nary_union.get_union();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue