[gdal-dev] Bytes still reachables in setFromUserInput function

Mathieu Coudert mathieu.coudert at gmail.com
Thu Jun 4 08:18:10 PDT 2015


Thanks Even for the prompt answer.
I would have expected a method through the OGR API to handle it without
having to call proj but if it appears like the standard or default way for
you to do it, let's do it.

Cheers,

Mathieu


On Thu, Jun 4, 2015 at 4:20 PM, Even Rouault <even.rouault at spatialys.com>
wrote:

> Le jeudi 04 juin 2015 16:04:32, Mathieu Coudert a écrit :
> > Hello,
> >
> >
> >
> > I am using GDAL 1.11.2 on linux Centos and here is one of my function :
> >
> >
> >
> > {
> >
> > OGRSpatialReference sr;
> >
> > if (sr.SetFromUserInput(proj.c_str()) != OGRERR_NONE)
> >
> >     throw InvalidInput();
> >
> >
> >
> > char *wkt;
> >
> > sr.exportToWkt(&wkt);
> >
> > string srs (wkt);
> >
> > OGRFree(wkt);
> >
> >
> >
> > return srs;
> >
> > }
> >
> >
> >
> > This code works fine but when I use Valgrind on it, I get the following
> > message :
> >
> >
> >
> > […] bytes still reachable at line X
> >
> > where X is the line with the setFromUserInput
> >
> > (please find below the full stacktrace)
> >
> >
> >
> > [...] are still reachable [...]
> >
> > ==22766==    at 0x4A06A2E: malloc (vg_replace_malloc.c:270)
> >
> > ==22766==    by 0x54EB3B7: pj_malloc (pj_malloc.c:19)
> >
> > ==22766==    by 0x54F67BB: pj_insert_initcache (pj_initcache.c:161)
> >
> > ==22766==    by 0x54EA388: get_init (pj_init.c:288)
> >
> > ==22766==    by 0x54EA57B: pj_init_ctx (pj_init.c:428)
> >
> > ==22766==    by 0x54EB154: pj_init_plus_ctx (pj_init.c:366)
> >
> > ==22766==    by 0x6A4978: OCTProj4Normalize (ogrct.cpp:309)
> >
> > ==22766==    by 0x6A3215: OGRSpatialReference::importFromEPSGA(int)
> > (ogr_fromepsg.cpp:2222)
> >
> > ==22766==    by 0x6A381B: OGRSpatialReference::importFromEPSG(int)
> > (ogr_fromepsg.cpp:2095)
> >
> > ==22766==    by 0x693E41: OGRSpatialReference::SetFromUserInput(char
> > const*) (ogrspatialreference.cpp:1955)
> >
> > ==22766==    by 0x44D70B:
> > GisKit::ProjToSRS(std::__cxx11::basic_string<char,
> std::char_traits<char>,
> > std::allocator<char> > const&) (GisKit.cpp:46)
> >
> >
> > Do you have any ideas?
>
> Mathieu,
>
> This is not lost memory, but cached proj.4 definitions. You could
> explicitely
> call pj_clear_initcache() (from proj_api.h) at the end of your process to
> clear that cache.
>
> Even
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20150604/a5e84ad4/attachment.html>


More information about the gdal-dev mailing list