[gdal-dev] Bytes still reachables in setFromUserInput function

Even Rouault even.rouault at spatialys.com
Thu Jun 4 07:20:53 PDT 2015


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


More information about the gdal-dev mailing list