I’m very new in using GDAL, and trying the tutorial given here.
But with a piece of code with only
GDALRegister_GTiff();
GDALDataset *poDataset = (GDALDataset *) GDALOpen(argv[1], GA_ReadOnly );
if( poDataset != NULL )
GDALClose( (GDALDatasetH) poDataset );
Valgrind says there is a memory leak with 32 bytes still reachable. Is there a memory leak in the GDALOpen function?
Edit: Valgrind’s output
==25399== 32 bytes in 1 blocks are still reachable in loss record 1 of 1
==25399== at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25399== by 0x660B68F: _dlerror_run (dlerror.c:141)
==25399== by 0x660B197: dlsym (dlsym.c:70)
==25399== by 0x51A7F27: GTiffOneTimeInit (geotiff.cpp:10764)
==25399== by 0x51B5382: GTiffDataset::Open(GDALOpenInfo*) (geotiff.cpp:6198)
==25399== by 0x53C17E7: GDALOpenInternal(GDALOpenInfo&, char const* const*) (gdaldataset.cpp:2318)
==25399== by 0x53C1A17: GDALOpenInternal(char const*, GDALAccess, char const* const*) (gdaldataset.cpp:2267)
==25399== by 0x4010D7: main (main.cpp:18)
Line 18 is:
GDALDataset *poDataset = (GDALDataset *) GDALOpen(argv[1], GA_ReadOnly );
However, I’ve followed the tutorial, and my program ends with:
/* Once we're done, close properly the dataset */
if( poDataset != NULL )
GDALClose( (GDALDatasetH) poDataset );
I just observed that if I give a filename directly as a string in GDALOpen instead of using a command line parameter, I don’t have the leak anymore.