Memory leak question

Any idea why I would get this memory leak?

==18391== 24 bytes in 1 blocks are definitely lost in loss record 294 of 568
==18391== at 0x4A1FF2C: malloc (vg_replace_malloc.c:195)
==18391== by 0x5A77DE9: H5MM_malloc (H5MM.c:64)
==18391== by 0x59761A2: H5FL_malloc (H5FL.c:175)
==18391== by 0x5976E83: H5FL_reg_malloc (H5FL.c:375)
==18391== by 0x5A76494: H5MF_sect_simple_new (H5MFsection.c:143)
==18391== by 0x5A71D21: H5MF_xfree (H5MF.c:487)
==18391== by 0x5A74B64: H5MF_aggr_alloc (H5MFaggr.c:214)
==18391== by 0x5A71350: H5MF_alloc (H5MF.c:376)
==18391== by 0x5A9310B: H5O_alloc_new_chunk (H5Oalloc.c:809)
==18391== by 0x5A94718: H5O_alloc (H5Oalloc.c:1008)
==18391== by 0x5AE7AED: H5O_msg_alloc (H5Omessage.c:1935)
==18391== by 0x5ADEBC0: H5O_msg_append_real (H5Omessage.c:227)
==18391== by 0x5AA2041: H5O_attr_create (H5Oattribute.c:345)
==18391== by 0x58244EE: H5A_create (H5A.c:494)
==18391== by 0x5821A8B: H5Acreate2 (H5A.c:246)
==18391== by 0x60181FA: H5::H5Object::createAttribute(char const*, H5::DataType const&, H5::DataSpace const&, H5::PropList const&) const (H5Object.cpp:111)
==18391== by 0x60183EB: H5::H5Object::createAttribute(std::string const&, H5::DataType const&, H5::DataSpace const&, H5::PropList const&) const (H5Object.cpp:132)
==18391== by 0x4B4C480: corestore::HDFFile::writeGroupAttributes(std::string const&, std::string const&, std::map<std::string, corestore::Attribute*, std::less<std::string>, std::allocator<std::pair<std::string const, corestore::Attribute*> > >&) (HDFFile.C:796)
...

The relevant code is here.

        {
            H5::DataType newAttrType(getHDFType(attrIt->second->getDataType(),
                attrIt->second->getStringLength()));
            hsize_t dims[1];
            dims[0] = attrIt->second->getLength();
            H5::DataSpace newAttrSpace(1, dims, NULL);
            H5::Attribute newAttr = baseGroup.createAttribute(attrIt->first,
                newAttrType, newAttrSpace); // <-- line 796
            newAttr.write(newAttrType, attrIt->second->getData());
        }

The newAttr object goes out of focus after this block so I think everything should be clean on my end. This is the only remaining memory leak I have found so it this shouldn't be being caused by another leak indirectly.

David McCloskey
Lead Programmer Analyst
Software Development
Core Engineering
Nuclear Fuel

Westinghouse Electric Company
Energy Center
4350 Northern Pike
Monroeville, PA, 15146, USA
Phone: +1 (412) 374-3789
Fax: +1 (412) 374-4500
Email: mcclosdl@westinghouse.com
Home Page: www.westinghousenuclear.com

Hi David,

There are a couple of memory leak bugs in the C++ library. We'll try to fix
them before our next release.

Thank you!
Binh-Minh

···

-----Original Message-----
From: hdf-forum-bounces@hdfgroup.org [mailto:hdf-forum-
bounces@hdfgroup.org] On Behalf Of McCloskey, David L.
Sent: Tuesday, April 20, 2010 4:21 PM
To: hdf-forum@hdfgroup.org
Subject: [Hdf-forum] Memory leak question

Any idea why I would get this memory leak?

==18391== 24 bytes in 1 blocks are definitely lost in loss record 294 of
568
==18391== at 0x4A1FF2C: malloc (vg_replace_malloc.c:195)
==18391== by 0x5A77DE9: H5MM_malloc (H5MM.c:64)
==18391== by 0x59761A2: H5FL_malloc (H5FL.c:175)
==18391== by 0x5976E83: H5FL_reg_malloc (H5FL.c:375)
==18391== by 0x5A76494: H5MF_sect_simple_new (H5MFsection.c:143)
==18391== by 0x5A71D21: H5MF_xfree (H5MF.c:487)
==18391== by 0x5A74B64: H5MF_aggr_alloc (H5MFaggr.c:214)
==18391== by 0x5A71350: H5MF_alloc (H5MF.c:376)
==18391== by 0x5A9310B: H5O_alloc_new_chunk (H5Oalloc.c:809)
==18391== by 0x5A94718: H5O_alloc (H5Oalloc.c:1008)
==18391== by 0x5AE7AED: H5O_msg_alloc (H5Omessage.c:1935)
==18391== by 0x5ADEBC0: H5O_msg_append_real (H5Omessage.c:227)
==18391== by 0x5AA2041: H5O_attr_create (H5Oattribute.c:345)
==18391== by 0x58244EE: H5A_create (H5A.c:494)
==18391== by 0x5821A8B: H5Acreate2 (H5A.c:246)
==18391== by 0x60181FA: H5::H5Object::createAttribute(char const*,
H5::DataType const&, H5::DataSpace const&, H5::PropList const&) const
(H5Object.cpp:111)
==18391== by 0x60183EB: H5::H5Object::createAttribute(std::string
const&, H5::DataType const&, H5::DataSpace const&, H5::PropList const&)
const (H5Object.cpp:132)
==18391== by 0x4B4C480:
corestore::HDFFile::writeGroupAttributes(std::string const&, std::string
const&, std::map<std::string, corestore::Attribute*,
std::less<std::string>, std::allocator<std::pair<std::string const,
corestore::Attribute*> > >&) (HDFFile.C:796)
...

The relevant code is here.

       {
           H5::DataType newAttrType(getHDFType(attrIt->second-

getDataType(),

               attrIt->second->getStringLength()));
           hsize_t dims[1];
           dims[0] = attrIt->second->getLength();
           H5::DataSpace newAttrSpace(1, dims, NULL);
           H5::Attribute newAttr = baseGroup.createAttribute(attrIt-

first,

               newAttrType, newAttrSpace);
// <-- line 796
           newAttr.write(newAttrType, attrIt->second->getData());
       }

The newAttr object goes out of focus after this block so I think everything
should be clean on my end. This is the only remaining memory leak I have
found so it this shouldn't be being caused by another leak indirectly.

David McCloskey
Lead Programmer Analyst
Software Development
Core Engineering
Nuclear Fuel

Westinghouse Electric Company
Energy Center
4350 Northern Pike
Monroeville, PA, 15146, USA
Phone: +1 (412) 374-3789
Fax: +1 (412) 374-4500
Email: mcclosdl@westinghouse.com
Home Page: www.westinghousenuclear.com

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

--
Internal Virus Database is out-of-date.
Checked by AVG.
Version: 7.5.549 / Virus Database: 270.9.0/1778 - Release Date: 11/9/2008
2:14 PM