This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Tom, > Thanks for the advice on the memory leaks in NcFile::sync(). We > applied them and the leaks are gone. Unfortunately, we don't You're welcome. I assume you mean "Fortunately" > use ncsync() to detect if another process has made changes to the > variables or dimensions. Our application is a single server that > satifies requests from a suite of clients. > > While we were at it, we found and corrected a memory leak in > NcTypeComponent::Nc_as() and as_string(). The changes are listed below. > If these are known leaks, please disregard them. If you have a > better solution, let us know and we'll be happy to install it instead. I didn't know about these leaks. I need to construct a test for all the member functions and then run it under Purify. Thanks for these fixes. Your solution looks workable to me. If you find any more leaks, please let me know. --Russ > - -------------- Old section of netcdf.cc ---------------------------- > > #define Nc_as(TYPE) name2(as_,TYPE) > #define NcTypedComponent_as(TYPE) \ > TYPE NcTypedComponent::Nc_as(TYPE)( int n ) const \ > { \ > return values()->Nc_as(TYPE)(n); \ > } > NcTypedComponent_as(ncbyte) > NcTypedComponent_as(char) > NcTypedComponent_as(short) > NcTypedComponent_as(long) > NcTypedComponent_as(float) > NcTypedComponent_as(double) > > char* NcTypedComponent::as_string( int n ) const > { > return values()->as_string(n); > } > > > > - ------------- Changes to remove leaks in netcdf.cc ---------------------- > #define Nc_as(TYPE) name2(as_,TYPE) > #define NcTypedComponent_as(TYPE) \ > TYPE NcTypedComponent::Nc_as(TYPE)( int n ) const \ > { \ > NcValues *tmp = values(); > \ > TYPE rval = tmp->Nc_as(TYPE)(n); > \ > delete tmp; > \ > return rval; > \ > } > NcTypedComponent_as(ncbyte) > NcTypedComponent_as(char) > NcTypedComponent_as(short) > NcTypedComponent_as(long) > NcTypedComponent_as(float) > NcTypedComponent_as(double) > > char* NcTypedComponent::as_string( int n ) const > { > NcValues *tmp = values(); > char *str = tmp->as_string(n); > delete tmp; > return str; > } > ------- end ------- ______________________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden P.O. Box 3000 http://www.unidata.ucar.edu/ Boulder, CO 80307-3000 ______________________________________________________________________________