Subject: CGAL users discussion list
List archive
- From: Sylvain Pion <>
- To:
- Subject: Re: [cgal-discuss] Crash when calling operator += with lazy_exact_nt
- Date: Thu, 25 Sep 2008 20:50:48 +0200
a écrit :
I have encountered a problem when using CGAL and I was wondering if anyone
knows how to fix this. The problem is that when I run the following code the
application crashes.
The code:
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel KERNEL;
typedef KERNEL::FT NUMBER_TYPE;
int main( int argc, char* argv[])
{
NUMBER_TYPE num1 = 4;
NUMBER_TYPE num2 = 3;
for (int i =0; i< 100000; i++)
{
num1+=num2;
}
num1 = 5;
num2 =4;
};
I compile the code with the following preprocessor definitions :
CGAL_USE_GMP;_SECURE_SCL=0
I use CGAL 3.3.1 downloaded from the site using the windows installer (when
tested with vs2005) and boost 1.35 from the Boost Consulting web site.
The code is compiled using Visual Studio 2005 and Visual Studio 2008 compilers
on Windows XP, Windows Vista. The application was tested on various different
computers (both Intel and AMD based). The runtime library is Multi-threaded
Debug when compiled in Debug and Multi-threaded when compiled in Release. It falls both for Debug and Release.
What I have noticed that when I run the loop for a small number of iterations
the application does not crash. When I increase the number of iterations, the
application crashes in Debug but not in Release. When I increase the number of
iterations furthermore, it also falls in Release.
Thanks for the nicely detailed report.
What you experience is however expected. Each arithmetic operation on
CGAL::Lazy_exact_nt<> (the type of NUMBER_TYPE) allocates a new node in
memory,
so memory gets filled quickly. Basically, it is not designed to support this
kind of cascaded/iterated operations. Maybe one way to make your example work
would be to call, say every 100 loop iterations, "num1.exact()".
Anyway, it could be more interesting to see your original application, to see
what the best solution is.
--
Sylvain Pion
INRIA Sophia-Antipolis
Geometrica Project-Team
CGAL, http://cgal.org/
- [cgal-discuss] Crash when calling operator += with lazy_exact_nt, shiranchok, 09/25/2008
- Re: [cgal-discuss] Crash when calling operator += with lazy_exact_nt, Sylvain Pion, 09/25/2008
Archive powered by MHonArc 2.6.16.