Memory leak in RadialDataset?

John Caron caron at unidata.ucar.edu
Tue Mar 20 09:35:48 MDT 2007


Don, do you have caching on?

Anyway, make sure caching is off (NetcdfFileCache.disable()). 

Yuan, can you check your code for anything obvious?

Jeff McWhirter wrote:
> 
> We seem to have a memory leak in RadialDataset when we create an RHI
> 
> Here is the scenario. I run the following loop, keeping around the 
> references to the adapter
> in the tmp list so they don't get collected. The getData call reads the 
> RHI or the sweep
> from the RadialDatasetSweep. The clear method in the adapter clears 
> internal references.
> 
>        while(true) {
>          CDMRadarAdapter adapter = new CDMRadarAdapter(this, file);
>          tmp.add(adapter);
>          adapter.getData(dataChoice, subset,
>                            requestProperties);
>          adapter.clear();
>        }
> 
> If I run this and do not clear the reference to the RadialDatasetSweep 
> that it holds then I get a big memory
> leak. If I clear the reference then no leak. So, this tells me that 
> somewhere in the RadialDatasetSweep world
> there a retained reference to data. Is there any caching going on here 
> on purpose? or is there a stray pointer
> to some data?
> 
> -Jeff
> 
> 



More information about the Netcdf-java mailing list