[Gdal-dev] gdal cache

Gillian Walter gillian.walter at atlantis-scientific.com
Wed Oct 13 12:05:59 EDT 2004


Hi,

I've done a test in python, and it doesn't seem to be flushing:

>>> import gdal
>>> jnk = gdal.Open('/tmp/tmptqTlGV')
>>> arr=jnk.GetRasterBand(1).ReadAsArray()
>>> arr[10,10]
(77+151j)
[copied a new same-size, same type file over /tmp/tmptqT1GV at this point]
>>>  jnk.FlushCache()
>>>  arr2=jnk.GetRasterBand(1).ReadAsArray()
>>> arr2[10,10]
(77+151j)
>>> jnk2=gdal.Open('/tmp/tmptqT1GV')
>>> arr3=jnk2.GetRasterBand(1).ReadAsArray()
>>> arr3[10,10]
(16+50j)
>>> jnk.GetRasterBand(1).FlushCache()
0
>>> arr2=jnk.GetRasterBand(1).ReadAsArray()
>>> arr2[10,10]
(77+151j)

Am I missing something else?

Thanks,

Gillian

Frank Warmerdam wrote:

> Gillian Walter wrote:
> > Hi,
> >
> > Is there any way to force gdal to flush its read cache? I've looked at
> > the dataset and raster band FlushCache methods, but they just seem to
> > write out any changes that have been made via gdal.  I am wondering if
> > there is any way to tell gdal that an external application has altered a
> > dataset.
>
> Gillian,
>
> The GDALRasterBand::FlushBlock() method will write out the block data if
> the block is dirty (altered in memory since reading from disk), and then
> it does "delete poBlock" which removes the block from the cache and recovers
> the memory.
>
> So, normal flushing should also get rid of the readcached block information.
>
> Best regards,
> --
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list