[gdal-dev] General Memory/Resource leak fixes(Cleanup calls)

sanjay boddhu sanjay_ieee at yahoo.com
Thu Jan 24 15:02:00 EST 2008


Hi Even,
            I'm using Visual studio  with devpartner and below is the part of my app(but reproduces the leaks i have mentioned), its just simply reading from a tif file and creating a another one:

main()
{
.........
.........
GDALAllRegister();
GDALDriver *drv = GetGDALDriverManager()->GetDriverByName("GTiff");
GDALDataset *in_img = (GDALDataset*) GDALOpen(input_file_name.c_str(), GA_ReadOnly);
GDALRasterBand *band = in_img->GetRasterBand(1);
unsigned short *in_buff = new unsigned short[size_x * size_y];
band->RasterIO(GF_Read, 0, 0, size_x, size_y, in_buff, size_x, size_y, GDT_UInt16, 0, 0);
GDALDataset *out_img = drv->Create(output_file_name.c_str(), size_x, size_y, 3, GDT_UInt16, NULL);
band = out_img->GetRasterBand(1);
        band->RasterIO(GF_Write, 0, 0, size_x, size_y, in_buff, size_x, size_y, GDT_UInt16, 0, 0);
        
 GDALClose( out_img );
 GDALClose( in_img );

 delete[] in_buff;

       
VSICleanupFileManager();
GDALDestroyDriverManager();
CPLCleanupTLS();
CPLFinderClean();
CPLFreeConfig();

.....
.....
}

Even Rouault <even.rouault at mines-paris.org> wrote: Hi,

If you want precise help, you should mention the exact version of GDAL you're 
using, and report the exact message you get from your memory leak detector, 
including filenames and line numbers. (If you use Valgrind under Linux, a 
Valgrind trace would help a lot). Your source code would of course help to 
see if it's a memory leak in GDAL or in the way you're using it in your code.

Best regards.

Le Thursday 24 January 2008 10:41:45 sanjay boddhu, vous avez écrit :
> Hi ,
>      I have been trying to fix (or to be more appropriate, find the cleanup
> calls to fix) the memory and resource leaks in my application(which uses
> GDAL to read and write to a tif file). I have tried all the cleanup calls
> mentioned in the end of :
>
> http://www.gdal.org/gdalinfo.c.html
>
> and reduced lot of memory/resource leaks......But i still get a memory leak
> pointing in "GDALDataset  Create( ...)"  and few resource leaks of Mutex
> and TLsAlloc.
>
> I would really appreciate if anyone can recommend the right cleanup calls
> for the above leaks or hint me in the right direction.
>
> Thanks
>
> Sanjay
>
>
>
> "If you look at what you do not have in life, you don't have anything"
> "If you look at what you have in life, you have everything"
>
> ---------------------------------
> Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it
> now.





"If you look at what you do not have in life, you don't have anything"
"If you look at what you have in life, you have everything"
       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20080124/5933adda/attachment-0001.html


More information about the gdal-dev mailing list