Re: [netcdf-java] NetcdfFileCache doesn't release OPeNDAP datasets

Jon Blower wrote:
Hi John (and list),

I've come across some behaviour in nj4 that was unexpected to me, but
is possibly a feature not a bug!  In ncWMS I'm using the cache of
datasets, which I'm initializing like so:

    // Hold between 50 and 500 datasets, refresh cache every 5 minutes
    NetcdfDataset.initNetcdfFileCache(50, 500, 500, 5 * 60);

Then I use NetcdfDataset.acquireDataset() to open datasets.
Everything seems to work fine for datasets that are read from local
files.  However, for datasets that are read from OPeNDAP locations,
the cache appears to hold on to the dataset forever: every call to
acquireDataset() returns the same dataset, even well after the
5-minute expiry period (in fact the dataset is only evicted on a
reboot of the server).

Therefore I use a function like this to get the behaviour I expect:

    public static NetcdfDataset openDataset(String location) {
        if (location.startsWith("http://";)) {
            return NetcdfDataset.openDataset(location);  // don't use the cache
        } else {
            // this is a local dataset: use the cache
            return NetcdfDataset.acquireDataset(location, null);
        }
    }

Is this a bug in nj4?

Hi Jon:

Yes, this is a bug. I will think about how to fix. Thanks for figuring it out.



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: