[netcdfgroup] memory leak in as_double()?

<72251B925CE10A478606EEAC6AA683BE0DA20C22AF@xxxxxxxxxxxxxxxxxxxxxxx>
Accept-Language: nb-NO, en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
acceptlanguage: nb-NO, en-US
Content-Type: multipart/alternative;
        boundary="_000_72251B925CE10A478606EEAC6AA683BE0DA20C22AFSINTEFEXMBX01_"
MIME-Version: 1.0
X-Loop:  netcdfgroup@xxxxxxxxxxxxxxxx

--_000_72251B925CE10A478606EEAC6AA683BE0DA20C22AFSINTEFEXMBX01_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable


Hello list,

NetCDF 4.0.1 Windows; pre-built netcdf.dll dated 29.09.08, C++ interface co=
mpiled into separate application.

I am wondering if there is a memory leak in the function (or macro) NcVar::=
as_double(), as defined in netcdf.cpp line 548.

I am terribly unfamiliar with macros and code blocks wrapped in #defines, a=
nd have a hard time understanding what happens.

Inside an NcFile object, my code does:

dt.m_dt =3D get_var(pTd->name())->as_double(pTd->size()-1);
// dt is a COleDateTime, dt.m_dt is a double
// pTd is a NcDim*

to get the last value of the coordinate variable associated with pTd.
When executing the offending line, the applications memory usage increases =
24 KB. A get_space() function called from the macro seems to allocate space=
 according to the total size of the variable.The size of pTd is approx. 270=
0, and with 8 byte double, 24 kB makes sense.
I do see the "delete tmp;" in netcdf.cpp line 538, but my compiler refuse t=
o trace into this macro and I'm unable to determine why the memory is not f=
reed.

Is this a memory leak, or am I being fooled by the Windows Task Manager's m=
emory usage state?

Best regards,

Sjur  K :-)




--_000_72251B925CE10A478606EEAC6AA683BE0DA20C22AFSINTEFEXMBX01_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.3790.4426" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial size=3D2>Hello=20
list,</FONT></SPAN></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><SPAN class=3D151225622-04032009><FO=
NT=20
face=3DArial size=3D2></FONT></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial><FONT size=3D2><SPAN class=3D151225622-04032009><FO=
NT=20
face=3DArial size=3D2>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial size=3D2>NetCDF 4.=
0.1=20
Windows; pre-built netcdf.dll dated 29.09.08, C++ interface compiled into=20
separate application.</FONT></SPAN></DIV>
<DIV><SPAN=20
class=3D151225622-04032009></SPAN>&nbsp;</DIV></FONT></SPAN></FONT></FONT><=
/DIV>
<DIV><FONT face=3DArial><FONT size=3D2><SPAN class=3D151225622-04032009>I a=
m wondering=20
if there is a memory leak in the function (or macro) NcVar::as_double(), as=
=20
defined in netcdf.cpp line 548.</SPAN></FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><SPAN class=3D151225622-04032009><FO=
NT=20
face=3DArial size=3D2>
<DIV><SPAN class=3D151225622-04032009></SPAN><SPAN=20
class=3D151225622-04032009></SPAN>&nbsp;</DIV></FONT></SPAN></FONT></FONT><=
/DIV>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial size=3D2>I am terr=
ibly=20
unfamiliar with macros and code blocks wrapped in&nbsp;#defines, and have a=
 hard=20
time understanding what happens.</FONT></SPAN></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><SPAN class=3D151225622-04032009><FO=
NT=20
face=3DArial size=3D2></FONT></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial size=3D2>Inside an=
 NcFile=20
object, my code does:</FONT></SPAN></DIV>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV><SPAN class=3D151225622-04032009>
<DIV><FONT face=3DArial size=3D2>dt.m_dt =3D=20
get_var(pTd-&gt;name())-&gt;as_double(pTd-&gt;size()-1);</FONT></DIV>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial size=3D2>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial size=3D2>// dt is =
a=20
COleDateTime, dt.m_dt is a double</FONT></SPAN></DIV>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial size=3D2>//&nbsp;p=
Td is a=20
NcDim*</FONT></SPAN></DIV>
<DIV><SPAN class=3D151225622-04032009>&nbsp;</DIV></SPAN></FONT></SPAN></DI=
V>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial size=3D2>to get th=
e last=20
value of the coordinate variable associated with&nbsp;pTd. </FONT></SPAN></=
DIV>
<DIV><SPAN class=3D151225622-04032009></SPAN><SPAN class=3D151225622-040320=
09><FONT=20
face=3DArial size=3D2>When executing&nbsp;the offending&nbsp;line, the appl=
ications=20
memory usage increases 24 KB. A get_space() function called from the macro =
seems=20
to allocate space according to the total size of the variable.The size of p=
Td is=20
approx. 2700, and with 8 byte double, 24 kB makes sense. </FONT></SPAN><SPA=
N=20
class=3D151225622-04032009><FONT face=3DArial size=3D2></FONT></SPAN></DIV>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial size=3D2>I do see =
the "delete=20
tmp;" in netcdf.cpp line 538, but my compiler refuse to trace into this mac=
ro=20
and I'm unable to determine why the memory is not freed.</FONT></SPAN></DIV=
>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial size=3D2>Is this a=
 memory=20
leak, or am I being fooled by the Windows Task Manager's memory usage=20
state?</FONT></SPAN></DIV>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial size=3D2>Best=20
regards,</FONT></SPAN></DIV>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial size=3D2>Sjur&nbsp=
; K=20
:-)</FONT></SPAN></DIV>
<DIV><SPAN class=3D151225622-04032009><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<P><FONT face=3DArial size=3D2></FONT>&nbsp;</P></SPAN></BODY></HTML>

--_000_72251B925CE10A478606EEAC6AA683BE0DA20C22AFSINTEFEXMBX01_--



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