[gdal-dev] Re: GDAL Java Binding meomory problem under intensive method calls

Even Rouault even.rouault at mines-paris.org
Fri Jan 6 05:30:54 EST 2012


ok I found what was going on. The issue is the call to ogr2ogr which calls
ogr.RegisterAll(). The effect of calling ogr.RegisterAll() when it has already
been called is to reload the drivers, which will invalidate any opened
datasource, like the one you use indirectly for the source layers. This
datasource then references a destroyed driver, and the crash is just the direct
consequence of that.

So the fix is to replace ogr.RegisterAll() by

        if( ogr.GetDriverCount() == 0 )

in ogrinfo.java and ogr2ogr.java. Just pushed to SVN trunk.

Otherwise, using ogrinfo.java for the use you make of it is really
over-complicated. Just use :

         if( ogr.GetDriverCount() == 0 )
         DataSource poDS = ogr.Open(src, false);
         List<Layer> layers = new ArrayList<Layer>();
         for(int i=0;i<poDS.GetLayerCount();i++)

Best regards,


More information about the gdal-dev mailing list