[geos-devel] GEOS, Shapely, DLLs, and memory

Mateusz Loskot mateusz at loskot.net
Tue Apr 28 15:22:46 EDT 2009


Ragi Y. Burhum wrote:
> 
>     Date: Mon, 27 Apr 2009 13:46:09 -0600
>     From: Charlie Savage <cfis at savagexi.com <mailto:cfis at savagexi.com>>
>     Subject: Re: [geos-devel] GEOS, Shapely, DLLs, and memory
>     To: GEOS Development List <geos-devel at lists.osgeo.org
>     <mailto:geos-devel at lists.osgeo.org>>
>     Message-ID: <49F60B81.8070304 at savagexi.com
>     <mailto:49F60B81.8070304 at savagexi.com>>
>     Content-Type: text/plain; charset="utf-8"
> 
> 
> 
>     Paul Ramsey wrote:
>     > On Mon, Apr 27, 2009 at 11:47 AM, Aron Bierbaum
>     <aronbierbaum at gmail.com <mailto:aronbierbaum at gmail.com>> wrote:
>     >
>     >> I have attached a patch for both GEOS and Shapely that we have been
>     >> testing with for a few weeks without any problems. Does anyone have a
>     >> better way to address this issue?
>     >
>     > Pretty simple patch... more C-API changes. Hmm. Perhaps GEOS 3.2 will
>     > be out sooner than one might expect.
>     >
>     > I don't have the smarts to know if there's a better way.
> 
>     There isn't.  For every piece of memory GEOS allocates and returns via
>     the capi (or C++ api), it must provide a function to free it.
> 
>     If you are using C++ you can get around it by providing a memory
>     deallocator for objects returned from GEOS (say for std::string in this
>     case) but for C you obviously can't do that.
> 
> 
> Well, there is another way (not necessarily "better"), which is to
> compile the GEOS dll yourself using the same runtime that you use in
> your main application. That is what I have been doing this whole time to
> avoid this issue.

It will not help.

You must not cross modules boundaries, it's well known issue on Windows
platform. See "How should I deallocate resources acquainted from GDAL on
Windows?" in GDAL FAQ and the two links below this Q&A:

http://trac.osgeo.org/gdal/wiki/FAQMiscellaneous#FAQ-Miscellaneous

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org


More information about the geos-devel mailing list