NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.


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

[UDUNITS #JVV-494568]: memory leaks in udunits2



Peggy,

> There seems to be memory leak with ut_read_xml/ut_free_system. Or there
> shoud be a different way to release memory for ut_read_xml. I wonder if
> this is related to our already reported issue on May 1st, 2008 (UDUNITS
> #JFZ-220995) by Sue. I am using the current version (2.1.9). Here is my test
> code:
> 
> for(int loopi=0; loopi<100; loopi++) {
> ut_system* uds = ut_read_xml(NULL);
> sleep(1);
> ut_free_system(uds);
> uds = NULL;
> }
> 
> The memory usage increased:
> 
> VIRT: From 100MB to ~2.5GB
> RES: From 20MB to ~700MB
> 
> Please, give me some guidance of this memory leak issue.

Thanks for sending this in.

I'm investigating now.  This might take some time.

> Thanks!
> 
> Peggy
> 
> P.S.
> 
> Here is valgrind result with only one iteration:
> 
> ==1201== 27,512,628 (82,464 direct, 27,430,164 indirect) bytes in 1,718
> blocks are definitely lost in loss record 11 of 13
> ==1201==    at 0x401D38B: malloc (vg_replace_malloc.c:149)
> ==1201==    by 0x440D361: utalloc (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x440D7D5: ut_create_buffer (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x440D87F: utrestart (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x440FBD5: ut_parse (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x44119D1: mapIdToUnit (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x4411BE3: mapIdsToUnit (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x4411CAB: mapNamesToUnit (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x4412573: endElement (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x4418E62: doContent (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x4419729: contentProcessor (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x4419B49: prologProcessor (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==
> ==1201==
> ==1201== 720,984 bytes in 44 blocks are possibly lost in loss record 12 of 13
> ==1201==    at 0x401D38B: malloc (vg_replace_malloc.c:149)
> ==1201==    by 0x440D361: utalloc (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x440D7F4: ut_create_buffer (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x440D87F: utrestart (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x440FBD5: ut_parse (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x44122A2: endElement (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x4418E62: doContent (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x4419729: contentProcessor (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x4419B49: prologProcessor (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x441AF34: prologInitProcessor (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x4413ADD: XML_ParseBuffer (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==    by 0x44156F1: XML_Parse (in
> /d1/ncar/rapShared/apps/mdv_utils/src/NetCDF2Mdv/udunits/install/lib/libudunits2.so.0.0.0)
> ==1201==
> ==1201== LEAK SUMMARY:
> ==1201==    definitely lost: 82,464 bytes in 1,718 blocks.
> ==1201==    indirectly lost: 27,430,164 bytes in 1,674 blocks.
> ==1201==      possibly lost: 720,984 bytes in 44 blocks.
> ==1201==    still reachable: 3,826 bytes in 219 blocks.
> 
> Thanks!
> 
> Peiqi


Regards,
Steve Emmerson

Ticket Details
===================
Ticket ID: JVV-494568
Department: Support UDUNITS
Priority: Normal
Status: Open