[prev in list] [next in list] [prev in thread] [next in thread]
List: postgis-users
Subject: Re: [GENERAL] [postgis-users] Union as an aggregate
From: David Blasby <dblasby () refractions ! net>
Date: 2003-09-30 23:25:44
Message-ID: 3F7A10F8.60309 () refractions ! net
[Download RAW message or body]
strk,
I've been looking for the source of the memory leak. I was able to
reproduce "the problem" on my Linux machine.
I couldnt find any reason for a leak. I had orginally thought that the
POSTGIS->GEOS or GEOS->POSTGIS converters might be leaking.
My first check was on the POSTGIS->GEOS converter.
I've attached a simple little .cpp program that creates polygons the
same way as the postgis code does. I checked with valgrind, and it
leaks a constant amount of memory (probably static structures inside
geos).
So, that indicates its not the POSTGIS->GEOS convertor. I also looked
at the postgis geomUnion() functions. I dont think there's a leak there.
I'm looking at the GEOS->POSTGIS converter and I think I might have
found a problem.
dave
ps. how do you pronounce "strk"? stUrk? stIrk?
["test6.cpp" (text/plain)]
// g++ -g test6.cpp -I/usr/local/include/geos -lgeos; ./a.out
// g++ -g test6.cpp -I/usr/local/include/geos -lgeos ; valgrind --leak-check=yes --num-callers=10 ./a.out
#include "stdio.h"
#include "io.h"
#include "geom.h"
using namespace geos;
//create a simple multi-polygon
Geometry *a()
{
GeometryFactory *geomFactory;
Geometry *g1, *g2 ;
Coordinate *c;
CoordinateList *cl;
LinearRing *outerRing;
vector<Geometry *> *innerRings=new vector<Geometry *>;
PrecisionModel *pm= new PrecisionModel();
geomFactory= new GeometryFactory( pm, -1);
LinearRing *innerRing;
vector<Geometry *> *polys=new vector<Geometry *>;
cl = new BasicCoordinateList(5);
c = new Coordinate(0, 0);
cl->setAt( *c ,0);
delete c;
c = new Coordinate(10, 0);
cl->setAt( *c ,1);
delete c;
c = new Coordinate(10, 10);
cl->setAt( *c ,2);
delete c;
c = new Coordinate(0, 10);
cl->setAt( *c ,3);
delete c;
c = new Coordinate(0, 0);
cl->setAt( *c ,4);
delete c;
outerRing = (LinearRing*) geomFactory->createLinearRing(cl);
cl = new BasicCoordinateList(5);
c = new Coordinate(2, 2);
cl->setAt( *c ,0);
delete c;
c = new Coordinate(4, 2);
cl->setAt( *c ,1);
delete c;
c = new Coordinate(4, 4);
cl->setAt( *c ,2);
delete c;
c = new Coordinate(2, 4);
cl->setAt( *c ,3);
delete c;
c = new Coordinate(2, 2);
cl->setAt( *c ,4);
delete c;
innerRing = (LinearRing *) geomFactory->createLinearRing(cl);
innerRings->push_back(innerRing);
g1 = geomFactory->createPolygon(outerRing, innerRings);
polys->push_back(g1);
g2 = geomFactory->createMultiPolygon(polys);
string s= g2->toString();
cout << "geom1 == "<<s << endl;
//delete g1;
//delete cl;
delete geomFactory;
delete pm;
return g2;
}
/// create geometry, union it, then delete it
void op()
{
Geometry *aa, *bb, *cc;
aa = a();
bb = a();
cc = aa->Union(bb);
delete aa;
delete bb;
delete cc;
}
int main(int argC, char* argV[])
{
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
op();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic