Visual Studio에서는 몇 가지 누수 (수 백 줄)를 보여 주며, 총 몇 MB가 넘습니다. 아래의 "helloWorld 예제"를 추적했습니다. H5 :: DataSet.getSpace() 줄을 주석 처리하면 누수가 사라집니다.이 코드가 누출되는 이유는 무엇입니까? (간단한 코드 닛펫)
#include "stdafx.h"
#include <iostream>
#include "cpp/H5Cpp.h"
int main(int argc, char *argv[])
{
_CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); // dump leaks at return
H5::H5File myfile;
try {
myfile = H5::H5File("C:\\Users\\yyy\\myfile.h5", H5F_ACC_RDONLY);
}
catch (H5::Exception& e) {
std::string msg(std::string("Could not open HDF5 file.\n") + e.getCDetailMsg());
throw msg;
}
H5::Group myGroup = myfile.openGroup("/so/me/group");
H5::DataSet myDS = myGroup.openDataSet("./myfloatvec");
hsize_t dims[1];
//myDS.getSpace().getSimpleExtentDims(dims, NULL); // <-- here's the leak
H5::DataSpace dsp = myDS.getSpace(); // The H5::DataSpace seems to leak
dsp.getSimpleExtentDims(dims, NULL);
//dsp.close(); // <-- doesn't help either
std::cout << "Dims: " << dims[0] << std::endl; // <-- Works as expected
return 0;
}
어떤 도움을 주시면 감사하겠습니다. 나는 이것을 몇 시간 동안 해왔다. 나는 더러운 코드를 싫어한다. ...
HS :: H5File이란 무엇입니까? dsMean.getSpace.getSimpleExtentDims 정의 란 무엇입니까? – dchhetri
더 많은 코드가 필요합니다. 'H5 :: DataSpace :: getSpace()'는 실제로 무엇을합니까? – Synxis
죄송합니다. 분명하지만 분명히 그렇지 않다고 생각했습니다. 그것들은 HDF5 라이브러리의 C++ 인터페이스의 함수입니다. 이 것은 다음과 같습니다. http://www.hdfgroup.org/HDF5/doc/cpplus_RM/classH5_1_1DataSet.html getSpace()는 데이터 크기를 얻을 수있는 DataSpace 사본을 반환합니다. – Ela782