Hi,
I have observed the following code leaks resources linearly with program
runtime (admittedly I checked only 1.8.19, but didn't see a reference to
this in the .20 release notes).
int main(int, char**) {
H5::CompType ct((size_t)8);
ct.insertMember("a", 0, H5::PredType::NATIVE_INT32);
ct.insertMember("b", 4, H5::PredType::NATIVE_INT32);
for (int i = 0; i < 100000; ++i) {
H5::IntType dt = ct.getMemberIntType(0);
std::cerr << dt.getSize(); // just some side effect in order not be
optimized away (I doubt it would though)
dt.close();
}
}
In my naive understanding this is due to the duplicate reference to
p_get_member_type() in:
IntType CompType::getMemberIntType(unsigned member_num) const
{
try {
IntType inttype(p_get_member_type(member_num));
f_DataType_setId(&inttype, p_get_member_type(member_num));
return(inttype);
}
catch (DataTypeIException& E) {
throw DataTypeIException("CompType::getMemberIntType",
E.getDetailMsg());
}
}
This then results in two identifiers of which only one can be close()d.
Note that this is not specific to integer member types.
If one insists on using the C++ types, creating member types in the
following fashion enabled me to close resources properly.
H5::IntType dt(H5Tget_member_type(ct.getId(), 0));
std::cerr << dt.getSize();
H5Idec_ref(dt.getId());
dt.close();
Kind regards,
Thomas
Hi Thomas,
Thank you for your report of the issue. It will be addressed in the next release.
Binh-Minh
···
________________________________
From: Hdf-forum <hdf-forum-bounces@lists.hdfgroup.org> on behalf of Thomas Krijnen <t.krijnen+hdf5_forum@gmail.com>
Sent: Monday, December 4, 2017 9:52 AM
To: hdf-forum@lists.hdfgroup.org
Subject: [Hdf-forum] H5cpp resource leak
Hi,
I have observed the following code leaks resources linearly with program runtime (admittedly I checked only 1.8.19, but didn't see a reference to this in the .20 release notes).
int main(int, char**) {
H5::CompType ct((size_t)8);
ct.insertMember("a", 0, H5::PredType::NATIVE_INT32);
ct.insertMember("b", 4, H5::PredType::NATIVE_INT32);
for (int i = 0; i < 100000; ++i) {
H5::IntType dt = ct.getMemberIntType(0);
std::cerr << dt.getSize(); // just some side effect in order not be optimized away (I doubt it would though)
dt.close();
}
}
In my naive understanding this is due to the duplicate reference to p_get_member_type() in:
IntType CompType::getMemberIntType(unsigned member_num) const
{
try {
IntType inttype(p_get_member_type(member_num));
f_DataType_setId(&inttype, p_get_member_type(member_num));
return(inttype);
}
catch (DataTypeIException& E) {
throw DataTypeIException("CompType::getMemberIntType", E.getDetailMsg());
}
}
This then results in two identifiers of which only one can be close()d. Note that this is not specific to integer member types.
If one insists on using the C++ types, creating member types in the following fashion enabled me to close resources properly.
H5::IntType dt(H5Tget_member_type(ct.getId(), 0));
std::cerr << dt.getSize();
H5Idec_ref(dt.getId());
dt.close();
Kind regards,
Thomas
Hi Binh-Minh,
Wonderful, thanks for all the good work.
Kind regards,
Thomas
···
On Mon, Dec 4, 2017 at 4:49 PM, Binh-Minh Ribler <bmribler@hdfgroup.org> wrote:
Hi Thomas,
Thank you for your report of the issue. It will be addressed in the next
release.
Binh-Minh
------------------------------
*From:* Hdf-forum <hdf-forum-bounces@lists.hdfgroup.org> on behalf of
Thomas Krijnen <t.krijnen+hdf5_forum@gmail.com>
*Sent:* Monday, December 4, 2017 9:52 AM
*To:* hdf-forum@lists.hdfgroup.org
*Subject:* [Hdf-forum] H5cpp resource leak
Hi,
I have observed the following code leaks resources linearly with program
runtime (admittedly I checked only 1.8.19, but didn't see a reference to
this in the .20 release notes).
int main(int, char**) {
H5::CompType ct((size_t)8);
ct.insertMember("a", 0, H5::PredType::NATIVE_INT32);
ct.insertMember("b", 4, H5::PredType::NATIVE_INT32);
for (int i = 0; i < 100000; ++i) {
H5::IntType dt = ct.getMemberIntType(0);
std::cerr << dt.getSize(); // just some side effect in order not
be optimized away (I doubt it would though)
dt.close();
}
}
In my naive understanding this is due to the duplicate reference to
p_get_member_type() in:
IntType CompType::getMemberIntType(unsigned member_num) const
{
try {
IntType inttype(p_get_member_type(member_num));
f_DataType_setId(&inttype, p_get_member_type(member_num));
return(inttype);
}
catch (DataTypeIException& E) {
throw DataTypeIException("CompType::getMemberIntType",
E.getDetailMsg());
}
}
This then results in two identifiers of which only one can be close()d.
Note that this is not specific to integer member types.
If one insists on using the C++ types, creating member types in the
following fashion enabled me to close resources properly.
H5::IntType dt(H5Tget_member_type(ct.getId(), 0));
std::cerr << dt.getSize();
H5Idec_ref(dt.getId());
dt.close();
Kind regards,
Thomas
_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5