[FWTools] OGRFeature memory problem?

Mateusz Łoskot mateusz at loskot.net
Mon May 15 11:32:33 EDT 2006

Mike Toothaker wrote:
> Mateusz Łoskot wrote:
>> Mike Toothaker wrote:
>>> Thank you very much for the quick response.  Using:
>>> OGRFeature::DestroyFeature( poFeature );
>>> Unfortunately gives the same result.
>> Hi,
>> Could you try to change your code as follows:
>> 1)    OGRPoint *poPoint = new OGRPoint();
>> Simply, put this point on the stack:
>> OGRPoint pt;
>> 2) Change oFeature->SetGeometryDirectly( poPoint );
>> to read:
>> oFeature->SetGeometry( &pt );
>> Is it working now?
> You are my new hero.  :-)

Actually, the hero is Frank Warmerdam who found that OGRPoint problem
when I was chatting with him about your issue on the #gdal channel :-)

> That seems to have done the trick.  So basically the problem wasn't
> in the cleaning up of the OGRFeature necessarily so much as probably
> cleaning up the OGRPoint object, is this correct?

Also, it seems you've found small bugs in the OGR Tutorial.
I've just applied appropriate changes, so it should be published soon.

Please, not the difference between SetGeometry and SetGeometryDirectly
in case of geometry ownership transfer.

> Thank you very much.  It worked on my little test, now hopefully it 
> will work in the real project as well.

Good luck.
In case of problems, don't hesitate to send a note.

Mateusz Łoskot

More information about the FWTools mailing list