Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Memory Management with Nef_polyhedra

Subject: CGAL users discussion list

List archive

[cgal-discuss] Memory Management with Nef_polyhedra


Chronological Thread 
  • From: schrodingersnewcat <>
  • To:
  • Subject: [cgal-discuss] Memory Management with Nef_polyhedra
  • Date: Thu, 24 Mar 2011 21:40:58 -0700 (PDT)

Hello all,

I have a program that is executing a large number of transformations on
Nef_polyhedra. As the program executes the memory allocated to it grows
extremely fast.

The goal of the code is to create a grid which tracks material properties at
each point, so I have to know what materials constitute the voxel
surrounding each grid point (CGAL makes this very easy by the way). Since
this is intended to be part of a program that I will eventually run on a
large parallel computer, with total execution time around 24 hours, I can't
afford to exhaust all of my available memory in the first twenty or so
minutes.

Code that follows exhibits the problem. I had to use ps to get memory info
since I can't get valgrind to work with Nef_polyhedra.


#include &lt;CGAL/basic.h&gt;
#include &lt;CGAL/Gmpq.h&gt;
#include &lt;CGAL/Exact_predicates_exact_constructions_kernel.h&gt;
#include &lt;CGAL/Extended_cartesian.h&gt;
#include &lt;CGAL/Polyhedron_3.h&gt;
#include &lt;CGAL/IO/Polyhedron_iostream.h&gt;
#include &lt;CGAL/Nef_polyhedron_3.h&gt;
#include
#include

typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::FT CoordType;
typedef CGAL::Polyhedron_3 Polyhedron;
typedef CGAL::Nef_polyhedron_3 Nef_polyhedron;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
typedef Kernel::Aff_transformation_3 Aff_transformation;

int main(int argc, char **argv)
{
std::string name(argv[0]);

Point p1(0,0,0);
Point p2(1,0,0);
Point p3(0,1,0);
Point p4(0,0,1);

Polyhedron P;
P.make_tetrahedron(p1,p2,p3,p4);
std::cout << P;

std::cout << "Make NP" << std::endl;
Nef_polyhedron NP(P);

std::cout << "Make Transformation" << std::endl;
Aff_transformation affTran(CGAL::IDENTITY);

int count = 10000;
if(argc >= 2)
{
count = atoi(argv[1]);
}

std::cout << "ps -eo pid -o comm -o rss -o vsz | grep " << name <<
std::endl;
std::cin.ignore();
for(int i = 0; i < count; ++i)
{
NP.transform(affTran);
}
std::cout << "ps -eo pid -o comm -o rss -o vsz | grep " << name <<
std::endl;
std::cin.ignore();

NP.clear();
std::cout << "ps -eo pid -o comm -o rss -o vsz | grep " << name <<
std::endl;
std::cin.ignore();

return 0;
}

--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Memory-Management-with-Nef-polyhedra-tp3404480p3404480.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.16.

Top of Page