[Gdal-dev] How to use GetLockedBlockRef

Frank Warmerdam warmerdam at pobox.com
Wed Apr 5 22:09:40 EDT 2006


Reiner Beck wrote:
> Hello list,
> Hello Frank,
> 
> after upgrading to GDAL 1.3.1 (from 1.2.6) the method 
> GDALRasterBand::GetBlockRef() is no longer available. It has been 
> replaced by GDALRasterBand::GetLockedBlockRef().
> 
> Simply replacing the call with GDALRasterBand::GetLockedBlockRef() does 
> work somehow. However, for large images the process will allocate the 
> whole memory of the system up to a degree where it becomes unusable.
> 
> I fixed that by releasing each band after accessing the tile data with 
> "block->DropLock()". This seems to work.
> 
> Question: Is this the supposed way to use the block cache? If not, a 
> short example would help ...

Reiner,

Yes, GetLockedBlockRef() and DropLock() should be used in combination
as you have.  The GetLockedBlockRef() documentation seems to be fairly
specific about that need.

I have made a pass through gdalrasterband.cpp correcting old references
to GetBlockRef().  If you notice any more please let me know.

I'm not keen to write an example of using GetLockedBlockRef(), partly
because while it is public, it is not an interface that I wish to
encourage much use of.

> The documentation for GDALRasterBand still contains references to 
> GetBlockRef. To avoid confusion I propose to remove or change that. 
> Further, I have the impression that some public member functions in 
> GDALRasterBlock shouldn't really be public, or am I supposed to use e.g. 
> Internalize()?

You are correct that some of the methods on the GDALRasterBlock are not
really intended to be used by application programmers although in theory
there would be no particular harm in it.   Actually, looking at the code
it could be quite bad to call Internalize() on a block that has already
been internalized.

The problem is that if I made these private I would need to do some
fiddling with friend classes and it just isn't something that has been
a problem for many people.

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    | President OSGF, http://osgeo.org




More information about the Gdal-dev mailing list