Skip to Content.
Sympa Menu

cgal-discuss - CGAL leaks memory?

Subject: CGAL users discussion list

List archive

CGAL leaks memory?


Chronological Thread 
  • From: Maarten Moesen <>
  • To:
  • Subject: CGAL leaks memory?
  • Date: Fri, 27 Oct 2006 17:22:53 +0200
  • Organization: Katholieke Universiteit Leuven

Dear CGAL Programmers,

I'm currently using CGAL 3.2 and I'm very happy with it. But I noticed
that my CGAL processes when they're running use increasing amounts of
memory, and do not release their memory although I do delete() etc.
properly.

I wrote the following little test program:

#include <CGAL/Memory_sizer.h>

#include <CGAL/Cartesian.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel_with_sqrt.h>

//struct Kernel : CGAL::Cartesian<double>{};
struct Kernel : CGAL::Exact_predicates_inexact_constructions_kernel {};
//struct Kernel : CGAL::Exact_predicates_exact_constructions_kernel {};
//struct Kernel :
CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt {};

typedef Kernel::Point_3 Point;
#include <iostream>
#include <vector>

int main() {

CGAL::Memory_sizer m;
std::cout << "Start of program: Virtual process size: " <<
m.virtual_size()
<< " Resident process size: " << m.resident_size() <<
std::endl;

int n = 2000000;

{
std::vector< double > doubles;
doubles.reserve(n);

for (int i = 0; i < n; ++i)
doubles.push_back(3*i);

std::cout << std::endl
<< "doubles allocated: Virtual process size: " <<
m.virtual_size()
<< " Resident process size: " << m.resident_size() <<
std::endl;
}

std::cout
<< "doubles destroyed: Virtual process size: " <<
m.virtual_size()
<< " Resident process size: " << m.resident_size() <<
std::endl;

{
std::vector< Point > pts;
pts.reserve(n);

for (int i = 0; i < n; ++i)
pts.push_back( Point(i, 3*i, -i*2) );

std::cout << std::endl
<< "Points allocated: Virtual process size: " <<
m.virtual_size()
<< " Resident process size: " << m.resident_size() <<
std::endl;
} // std::vector goes out of scope here

std::cout << "Points destroyed: Virtual process size: " <<
m.virtual_size()
<< " Resident process size: " << m.resident_size() <<
std::endl;

return 0;
}

The output for the inexact constructions kernel is OK for me:

Start of program: Virtual process size: 21598208 Resident process size:
9842688

doubles allocated: Virtual process size: 37605376 Resident process size:
25890816
doubles destroyed: Virtual process size: 21602304 Resident process size:
9887744

Points allocated: Virtual process size: 69603328 Resident process size:
57888768
Points destroyed: Virtual process size: 21602304 Resident process size:
9887744

But all other kernels yield something like: (here Cartesian<double>)

Start of program: Virtual process size: 21594112 Resident process size:
9842688

doubles allocated: Virtual process size: 37601280 Resident process size:
25890816
doubles destroyed: Virtual process size: 21598208 Resident process size:
9887744

Points allocated: Virtual process size: 93536256 Resident process size:
81891328
Points destroyed: Virtual process size: 85532672 Resident process size:
73887744

How come that this last value is so high? What am I doing wrong?
I would expect that it goes back to normal as with the doubles and the
inexact constructions kernel. (This is the reason why my processes grow
so large... )

BTW: I'm using CGAL 3.2 and g++ 4.0.3 on a linux system
Program compiled with -O2 and -DNDEBUG
The Memory sizer seems to work fine, it gives about the same as top does
and the memory-widgets on my pc.

Thank you very much,

Maarten Moesen
--
ir. Maarten Moesen
Department of Metallurgy and Materials Engineering (MTM)
K.U.Leuven
Kasteelpark Arenberg 44
B-3001 Heverlee, Belgium
tel. +32 (0)16 32 13 17
fax. +32 (0)16 32 19 90


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm




Archive powered by MHonArc 2.6.16.

Top of Page