[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 20020313: ncendef error



>From: "V. Lakshmanan" <address@hidden>
>Subject: ncendef error ...
>Organization: National Severe Storms Laboratory
>Keywords: 200203131925.g2DJPSa00726 netCDF ncendef

Lak,

> I followed your suggestion and am doing a lsof and simply counting
> the number of lines each time:
> 
> #!/bin/sh
> while true
> do
> /usr/sbin/lsof -c $* | grep -v .so | wc
> sleep 1
> done
> 
> and it is holding steady at 12 files.  I am using the
> C++ interface, and the NcFile destructor should take
> care of calling ncclose() ...  I have written about 800
> files so far and it never went beyond 14 files open
> at a time.
> 
> but then the program hasn't crashed yet ...

The C++ interface makes the user responsible for deleting
some of the returned values and arrays, so it may not be enough to
just have the destructor call close.  I think you mentioned that the
process was not running out of memory, but this still might be worth
checking:

  ... Member functions that return pointers to attributes (`NcAtt')
  pass ownership to the calling function; users should delete
  attributes when they are finished with them.

  ...

  [For NcVar and NcAtt]

  `NcValues* values( void ) const'
     Returns a pointer to the block of all values for the variable or
     attribute.  The caller is responsible for deleting this block of
     values when no longer needed, as well as the pointer returned by
     the `values' method.  Note that this is not a good way to read
     selected values of a variable; use the `get' member function
     instead, to get single values or selected cross-sections of values.

  `long* edges( void ) const'
     Returns the shape of the variable, in the form of a vector
     containing the sizes of the dimensions of the variable.  The
     caller is responsible for deleting the returned edge vector when
     no longer needed.

   ...

  `NcAtt* get_att( int n ) const'
     The first member function returns a variable attribute by name.
     The second returns the n-th (starting at 0) attribute of the
     variable.  In either case, if no such attribute has been attached
     to the variable, zero is returned.  Attributes returned in this
     way belong to the caller, and hence should eventually be deleted
     by the caller to avoid memory leaks.

--Russ