Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Memory leak in snap_rounding_2?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Memory leak in snap_rounding_2?


Chronological Thread 
  • From: Philipp Moeller <>
  • To: Steven <>
  • Cc:
  • Subject: Re: [cgal-discuss] Memory leak in snap_rounding_2?
  • Date: Tue, 22 Oct 2013 16:10:29 +0200
  • Organization: GeometryFactory

Steven
<>
writes:

> First of all, please note that I am in the first place developing in C#, and
> only just started maintenance work on a native C++ library which uses CGAL.
> So please bear with me if I'm missing something obvious.
>
> The problem I believe to have located is the /Multiple_kd_tree *
> mul_kd_tree/ in the snap_rounding_2 constructor. This tree gets created in
> /s.find_hot_pixels_and_create_kd_trees/, is used by /s.iterate/, but
> immediately after that the constructor ends. This means that the
> Multiple_kd_tree, nor any of its children, get freed.
>
> I would appreciate it if someone with more C++ experience than me could take
> a look at this, to confirm if I managed to locate the issue correctly. Also,
> if possible, please advise on how i can correct this problem.

Your analysis looks correct. A quick fix is to `delete mul_kd_tree;`
after iterate has been called in the snap_rounding_2() function. This
should at least fix the leak of the Multiple_kd_tree.

Unfortunately Multiple_kd_tree itself seems to be leaking all its
Kd_tree children. To fix that a destructor would need to be added that
cleans up the kd_trees_list.

Another oddity is that snap_rounding_2() doesn't accept its Traits as an
argument. Maybe someone with better knowledge can apply a patch and fix
this at the same time.



Archive powered by MHonArc 2.6.18.

Top of Page