{"action":"closed","issue":{"url":"https://api.github.com/repos/open62541/open62541/issues/1928","repository_url":"https://api.github.com/repos/open62541/open62541","labels_url":"https://api.github.com/repos/open62541/open62541/issues/1928/labels{/name}","comments_url":"https://api.github.com/repos/open62541/open62541/issues/1928/comments","events_url":"https://api.github.com/repos/open62541/open62541/issues/1928/events","html_url":"https://github.com/open62541/open62541/issues/1928","id":342366998,"node_id":"MDU6SXNzdWUzNDIzNjY5OTg=","number":1928,"title":"Memory leak detected after using UA_Server_ReadValue()","user":{"login":"SebastianGraeber","id":34660814,"node_id":"MDQ6VXNlcjM0NjYwODE0","avatar_url":"https://avatars1.githubusercontent.com/u/34660814?v=4","gravatar_id":"","url":"https://api.github.com/users/SebastianGraeber","html_url":"https://github.com/SebastianGraeber","followers_url":"https://api.github.com/users/SebastianGraeber/followers","following_url":"https://api.github.com/users/SebastianGraeber/following{/other_user}","gists_url":"https://api.github.com/users/SebastianGraeber/gists{/gist_id}","starred_url":"https://api.github.com/users/SebastianGraeber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SebastianGraeber/subscriptions","organizations_url":"https://api.github.com/users/SebastianGraeber/orgs","repos_url":"https://api.github.com/users/SebastianGraeber/repos","events_url":"https://api.github.com/users/SebastianGraeber/events{/privacy}","received_events_url":"https://api.github.com/users/SebastianGraeber/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-07-18T14:59:22Z","updated_at":"2018-07-19T18:05:37Z","closed_at":"2018-07-19T18:05:37Z","author_association":"NONE","body":"Description\r\n===========\r\nHi,\r\n\r\nI'm developing an OPC UA server using VS 2017 Pro. The follwoing code is used:\r\n\r\n// +++START+++\r\nUA_ServerConfig l_UaServerConfig = UA_ServerConfig_standard;\r\nUA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, l_dlgEdasOpcUaServerGuiDlg->m_iOpcUaPort);\r\nl_UaServerConfig.networkLayers = &nl;\r\nl_UaServerConfig.networkLayersSize = 1;\r\nUA_Server *l_UaServer = UA_Server_new(l_UaServerConfig);\r\n\r\nstd::vector<UA_VariableAttributes> l_OpcWriteVarAttr(l_WriteValueCnt);\r\nstd::vector<UA_Float> l_OpcWriteValue(l_WriteValueCnt);\r\nstd::vector<UA_QualifiedName> l_OpcWriteName(l_WriteValueCnt);\r\nstd::vector<UA_NodeId> l_OpcWriteNodeValue(l_WriteValueCnt);\r\nstd::vector<UA_NodeId> l_OpcWriteNodeParent(l_WriteValueCnt);\r\nstd::vector<UA_NodeId> l_OpcWriteNodeParentRef(l_WriteValueCnt);\r\n\r\n#pragma omp parallel for\r\nfor (int i = 0; i < 100; i++)\r\n{\r\n\tUA_VariableAttributes_init(&l_OpcWriteVarAttr[i]);\r\n\tl_OpcWriteValue[i] = -99999.0;\r\n\tl_OpcWriteVarAttr[i].valueRank = -1;\r\n\tUA_Variant_setScalar(&l_OpcWriteVarAttr[i].value, &l_OpcWriteValue[i], &UA_TYPES[UA_TYPES_FLOAT]);\r\n\tl_OpcWriteVarAttr[i].description = UA_LOCALIZEDTEXT(\"de_de\", l_WriteNameList.GetAt(i).GetBuffer());\r\n\tl_OpcWriteVarAttr[i].displayName = UA_LOCALIZEDTEXT(\"de_de\", l_WriteNameList.GetAt(i).GetBuffer());\r\n\tl_OpcWriteVarAttr[i].accessLevel = UA_ACCESSLEVELMASK_READ | UA_ACCESSLEVELMASK_WRITE;\r\n\tl_OpcWriteVarAttr[i].dataType = UA_TYPES[UA_TYPES_FLOAT].typeId;\r\n\tl_OpcWriteName[i] = UA_QUALIFIEDNAME(1, l_WriteNameList.GetAt(i).GetBuffer());\r\n\tl_OpcWriteNodeValue[i] = UA_NODEID_STRING(1, l_WriteNameList.GetAt(i).GetBuffer());\r\n\tl_OpcWriteNodeParent[i] = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);\r\n\tl_OpcWriteNodeParentRef[i] = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);\r\n\tUA_Server_addVariableNode(l_UaServer, l_OpcWriteNodeValue[i], l_OpcWriteNodeParent[i], l_OpcWriteNodeParentRef[i], l_OpcWriteName[i], UA_NODEID_NULL, l_OpcWriteVarAttr[i], NULL, NULL);\r\n}\r\nUA_Server_run_startup(l_UaServer);\r\n\r\nwhile (true)\r\n{\r\n\tUA_Server_run_iterate(l_UaServer, false);\r\n\r\n#pragma omp parallel for\r\n\tfor (int i = 0; i < 100; i++)\r\n\t{\r\n\t\tUA_Server_readValue(l_UaServer, l_OpcWriteNodeValue[i], &l_OpcWriteVarAttr[i].value);\r\n\t\tl_EdasWriteValues[i] = *(UA_Float*)l_OpcWriteVarAttr[i].value.data;\r\n\t}\r\n        // Clocking\r\n        Sleep(100);\r\n}\r\nUA_Server_run_shutdown(l_UaServer);\r\nUA_Server_delete(l_UaServer);\r\nl_UaServer = NULL;\r\n\r\nnl.deleteMembers(&nl);\r\n// ---END---\r\n\r\nThe OPC UA server works as expected (transfer of values in both directions), but while executing the server, the memory increases. VS 2017 detects memory leaks after closing the application.\r\nIt seems that the following function produces the increasing memory that is never released:\r\nVS Call Stack:\r\n\r\nEdasOpcUaServerGui.exe!UA_Array_copy() - Line 5748\tC++\r\n\r\nWhat might cause this issue?\r\n\r\nUA_Server_WriteValue() works as expected without a memory increase.\r\n\r\nBackground Information / Reproduction Steps\r\n===========================================\r\nI'm using Version 0.2, but the same behavoiour occurred with 0.3rc1 and 03.rc2. No other OPC UA SDKs are used.\r\nOS: Windows 10 x64 Pro\r\n\r\n\r\n\r\nChecklist\r\n=========\r\nPlease provide the following information:\r\n\r\n - [x] open62541 Version (release number or git tag):\r\n - [x] Other OPC UA SDKs used (client or server): \r\n - [x] Operating system:\r\n - [ ] Logs (with `UA_LOGLEVEL` set as low as necessary) attached\r\n - [ ] Wireshark network dump attached\r\n - [ ] Self-contained code example attached\r\n - [ ] Critical issue\r\n"}}
{"actor":{"display_login":"SebastianGraeber"}}