[Gdal-dev] Re: reference counting

Frank Warmerdam warmerdam at pobox.com
Sat Aug 2 19:15:42 EDT 2003


Diana Esch-Mosher wrote:
> Frank,
> 
> GDALOpen() sets nREfCount=1,  nGDALDatasetCount++, and adds the dataset
> being created to  papoGDALDatasetList
> 
> GDALClose() calls GDALGetOpenDataset() which returns  nGDALDatasetCount
> and papoGDALDatasetList
> 
> Thus, whether a dataset is "shared" or not it always goes through the
> "shared" code in GDALClose() and dereferences!
> 
> Should it not be checking the bShared flag too?
> 
> This is causing me some problems in my openev app ....

Diana,

Things are kind of fuzzy in this area.  The current rules (as you have
discovered) is for GDALClose() to always just dereference datasets with a
ref count over 1 regardless of whether they are shared or not.  The shared
flag really is just used by GDALOpenShared() to determine existing datasets
that could be returned instead of creating a new one.

Can you outline the situation where this causes problems?  Is it that there
are extra references left on a dataset in some situations?   While I should
clearly fix up the internal documentation, I am not sure I want to change the
current active code unless you can show why it is problematic.

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