Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Re: Minkowski_sum_3 memory leak?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Re: Minkowski_sum_3 memory leak?


Chronological Thread 
  • From: Philipp Moeller <>
  • To: mastair <>
  • Cc:
  • Subject: Re: [cgal-discuss] Re: Minkowski_sum_3 memory leak?
  • Date: Fri, 08 Feb 2013 11:03:55 +0100
  • Organization: GeometryFactory

mastair
<>
writes:

> Yes, I posted the new error message a tad before you.
>
> Please provide some directions for me to help you fix this problem.

I just moved a patch to testing. The code is leak-free when I check it
with gperftools in strict mode. Let me know if MSVC believes the same.

commit 3a0932f578fa89112acb456c23671dcd260cfd27
Author: Philipp Möller <>
Date:   Fri Feb 8 00:25:20 2013 +0100

    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

	Modified   Minkowski_sum_3/include/CGAL/Minkowski_sum_3/bipartite_nary_union_sorted_combined.h
diff --git a/Minkowski_sum_3/include/CGAL/Minkowski_sum_3/bipartite_nary_union_sorted_combined.h b/Minkowski_sum_3/include/CGAL/Minkowski_sum_3/bipartite_nary_union_sorted_combined.h
index d9500a2..4f156d0 100644
--- a/Minkowski_sum_3/include/CGAL/Minkowski_sum_3/bipartite_nary_union_sorted_combined.h
+++ b/Minkowski_sum_3/include/CGAL/Minkowski_sum_3/bipartite_nary_union_sorted_combined.h
@@ -220,6 +220,16 @@ bipartite_nary_union_sorted_combined(Nef_polyhedron& N0,
     Ntmp.delegate(Convertor, true);
     CGAL_assertion(Ntmp.is_valid());
     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();



Archive powered by MHonArc 2.6.18.

Top of Page