Hello,
I'm using v1.2-rc2-45-gf4270ceb.
The callstack:
ucrtbased.dll!00007ffaa2cc1ea0() Unknown
ucrtbased.dll!00007ffaa2cc54a5() Unknown
ucrtbased.dll!00007ffaa2cc5bb8() Unknown
readTree.exe!UA_Array_delete(void * p, unsigned __int64 size, const UA_DataType * type) Line 9179 C
readTree.exe!String_clear(UA_String * s, const UA_DataType * _) Line 7950 C
readTree.exe!NodeId_clear(UA_NodeId * p, const UA_DataType * _) Line 8085 C
readTree.exe!ExpandedNodeId_clear(UA_ExpandedNodeId * p, const UA_DataType * _) Line 8232 C
readTree.exe!clearStructure(void * p, const UA_DataType * type) Line 9020 C
readTree.exe!UA_clear(void * p, const UA_DataType * type) Line 9108 C
readTree.exe!UA_Array_delete(void * p, unsigned __int64 size, const UA_DataType * type) Line 9175 C
readTree.exe!clearStructure(void * p, const UA_DataType * type) Line 9025 C
readTree.exe!UA_clear(void * p, const UA_DataType * type) Line 9108 C
readTree.exe!UA_Array_delete(void * p, unsigned __int64 size, const UA_DataType * type) Line 9175 C
readTree.exe!clearStructure(void * p, const UA_DataType * type) Line 9025 C
readTree.exe!UA_clear(void * p, const UA_DataType * type) Line 9108 C
readTree.exe!UA_BrowseResponse_clear(UA_BrowseResponse * p) Line 23230 C++
> readTree.exe!collectNodeIds(std::vector<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,UA_NodeId>,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,UA_NodeId> > > & nodeIds, UA_NodeId fromNodeId, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & prefixForOutput) Line 182 C++
readTree.exe!collectNodeIds(std::vector<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,UA_NodeId>,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,UA_NodeId> > > & nodeIds, UA_NodeId fromNodeId, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & prefixForOutput) Line 177 C++
readTree.exe!main(int argc, char * * argv) Line 281 C++
[External Code]
Source code of my user function (which is supposed to recursively collect NodeIds of all child nodes of a given node, so that they can later be used in a read request):
void collectNodeIds(vector<pair<string, UA_NodeId>>& nodeIds,
UA_NodeId fromNodeId,
const string& prefixForOutput)
{
UA_BrowseRequest bReq;
UA_BrowseRequest_init(&bReq);
bReq.requestedMaxReferencesPerNode = 0;
bReq.nodesToBrowse = UA_BrowseDescription_new();
bReq.nodesToBrowseSize = 1;
bReq.nodesToBrowse[0].nodeId = fromNodeId;
bReq.nodesToBrowse[0].resultMask = UA_BROWSERESULTMASK_ALL; /* return everything */
auto bResp = UA_Client_Service_browse(g_client, bReq);
for (size_t i = 0; i < bResp.resultsSize; ++i)
{
for (size_t j = 0; j < bResp.results[i].referencesSize; ++j)
{
auto* ref = &(bResp.results[i].references[j]);
if (ref->referenceTypeId.identifier.numeric == UA_NS0ID_HASCOMPONENT
|| ref->referenceTypeId.identifier.numeric == UA_NS0ID_ORGANIZES)
{
auto browseName = string(reinterpret_cast<char*>(ref->browseName.name.data), ref->browseName.name.length);
auto name = prefixForOutput + "." + browseName;
if (ref->typeDefinition.nodeId.identifierType == UA_NODEIDTYPE_NUMERIC
&& ref->typeDefinition.nodeId.identifier.numeric == UA_NS0ID_BASEDATAVARIABLETYPE)
nodeIds.emplace_back(make_pair(name, ref->nodeId.nodeId));
else
collectNodeIds(nodeIds, ref->nodeId.nodeId, name); // Recursion
}
}
}
UA_BrowseResponse_clear(&bResp);
UA_BrowseRequest_clear(&bReq);
}
What else could be helpful to find the cause?
Or did I misunderstand how to use the *_clear functions?
If I don't call UA_BrowseResponse_clear, Visual Leak Detector reports numerous memory leaks.
Regards
A. Geisler