Le mardi 16 avril 2013 22:07:52, Eli Adam a écrit :
> Even,
> 
> Thanks for checking into this and the ideas.

I've investigated a bit and I've discovered that while computing overviews, 
libtiff constantly switches from TIFF "directories" (main image, first 
overview,second overview, etc...). While doing this, it calls each time client 
code to install its own TIFF tags (libgeotiff for the geotiff tags, GDAL for 
the 
GDAL specific TIFF tags), but doesn't reset its array of existing tags. So each 
time the tags are added again and again, hence the huge memory allocation.

Could you test the attached patch (assuming you build GDAL with internal 
libtiff) ?

It would be good if you could also open a ticket in Trac about that issue.

Even

> 
> Eli
> 
Index: frmts/gtiff/libtiff/tif_dir.c
===================================================================
--- frmts/gtiff/libtiff/tif_dir.c	(révision 25916)
+++ frmts/gtiff/libtiff/tif_dir.c	(copie de travail)
@@ -1302,8 +1302,20 @@
 	tif->tif_tagmethods.printdir = NULL;
 	/*
 	 *  Give client code a chance to install their own
-	 *  tag extensions & methods, prior to compression overloads.
+	 *  tag extensions & methods, prior to compression overloads,
+     *  but do some prior cleanup first.
 	 */
+    if (tif->tif_nfieldscompat > 0) {
+        uint32 i;
+
+        for (i = 0; i < tif->tif_nfieldscompat; i++) {
+                if (tif->tif_fieldscompat[i].allocated_size)
+                        _TIFFfree(tif->tif_fieldscompat[i].fields);
+        }
+        _TIFFfree(tif->tif_fieldscompat);
+        tif->tif_nfieldscompat = 0;
+        tif->tif_fieldscompat = NULL;
+    }
 	if (_TIFFextender)
 		(*_TIFFextender)(tif);
 	(void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to