Hello this question is a continuation of this question. Provided below is a short version of the code that is loading the data into the structure. The HDF5DotNet library is found here using the 32 bit version with vs2015. My question is, will MyStruct leak memory when SomeCallerClass call HDF5GetSubGroups?
using HDF5DotNet;
namespace CommonClass
{
public class HDF5FileReader
{
public static List<string> HDF5GetSubGroups(string filePath)
{
var returnList = new List<string>();
//... some HDF5 instantiating -- commented out for brevity
var myStruct = new MyStruct[numberOfThingsToRead];
H5A.read(someAttribute, someAttributeType, new H5Array<MyStruct>(myStruct));
string myStructVariableString = IntPtrToString(myStruct[0].intPtr);
returnList.Add(myStructVariableString);
//... closing some HDF5 instantiating -- commented out for brevity
return returnList
}
private string IntPtrToString(IntPtr ipp)
{
string s = Marshal.PtrToStringAnsi(ipp)
//need to free ipp?
return s;
}
}
public struct MyStruct
{
public Int int1;
public IntPtr intPtr;
}
}
namespace CallerClass
{
public class SomeCallerClass()
{
string someFilePath = "Path\To\HDF5File.h5"
var stringList = HDF5FileReader.HDF5GetSubGroups(someFilePath)
//Do Something with StringList -- add to observablecollection
}
public class UnloadingSomeCallerClass()
{
//Clear the observablecollection
}
}