{"action":"created","issue":{"url":"https://api.github.com/repos/acplt/open62541/issues/348","labels_url":"https://api.github.com/repos/acplt/open62541/issues/348/labels{/name}","comments_url":"https://api.github.com/repos/acplt/open62541/issues/348/comments","events_url":"https://api.github.com/repos/acplt/open62541/issues/348/events","html_url":"https://github.com/acplt/open62541/issues/348","id":103504009,"number":348,"title":"Memory leak connect/new client or SIGSEGV","user":{"login":"tpiat","id":13619956,"avatar_url":"https://avatars.githubusercontent.com/u/13619956?v=3","gravatar_id":"","url":"https://api.github.com/users/tpiat","html_url":"https://github.com/tpiat","followers_url":"https://api.github.com/users/tpiat/followers","following_url":"https://api.github.com/users/tpiat/following{/other_user}","gists_url":"https://api.github.com/users/tpiat/gists{/gist_id}","starred_url":"https://api.github.com/users/tpiat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tpiat/subscriptions","organizations_url":"https://api.github.com/users/tpiat/orgs","repos_url":"https://api.github.com/users/tpiat/repos","events_url":"https://api.github.com/users/tpiat/events{/privacy}","received_events_url":"https://api.github.com/users/tpiat/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-08-27T13:06:02Z","updated_at":"2015-08-28T08:14:30Z","closed_at":null,"body":"I have next code\r\nIf I use \r\n\t\t\tUA_Client_disconnect(node.client);\r\n\t\t\tUA_Client_delete(node.client);\r\nI receive SIGSEGV, if I'll comment <B>UA_Client_disconnect(node.client);</B>, I'll get memory leak.\r\n\r\nEven if I don't use UA_Client_delete/UA_Client_new, I get memory leak.\r\n\r\nWindows 7, GCC.\r\n\r\nProbably I wrote incorrect program. \r\nCode is below.\r\n\r\n```\r\n#include \"open62541.h\"\r\n#include <string>\r\n\r\nusing namespace std;\r\n\r\nstruct OPCUA_Nodes\r\n{\r\n\tstring ip;\r\n\tUA_Client *client;\r\n\tint client_connected;\r\n\tUA_ReadRequest *rReq;\r\n};\r\n\r\nOPCUA_Nodes node;\r\n\r\nvoid core_Logger(UA_LogLevel level, UA_LogCategory category, const char *msg, ...)\r\n{\t\r\n}\r\n\r\nint localget()\r\n{\r\n\tstring uri(\"opc.tcp://\");\r\n\turi+=node.ip;\r\n\r\n\tif(!node.client_connected)\r\n\t{\t\t\r\n\t\tUA_StatusCode retval = UA_Client_connect(node.client, ClientNetworkLayerTCP_connect,(char *)uri.c_str());\r\n\t\tif(retval != UA_STATUSCODE_GOOD)\r\n\t\t{\r\n\t\t\tUA_Client_disconnect(node.client);\r\n\t\t\tUA_Client_delete(node.client);\r\n\t\t\tnode.client = UA_Client_new(UA_ClientConfig_standard, core_Logger);\r\n\t\t\tnode.client_connected=0;\r\n\t\t\treturn retval;\r\n\t\t}\r\n\t\telse node.client_connected=1;\r\n\t}\r\n\r\n\tUA_ReadResponse rResp = UA_Client_read(node.client, node.rReq);\r\n\tif(rResp.responseHeader.serviceResult != UA_STATUSCODE_GOOD)\r\n\t{\r\n\t\tnode.client_connected=0;\t\t\r\n\t}\r\n\tUA_ReadResponse_deleteMembers(&rResp);\r\n\r\n\treturn 0;\r\n}\r\n\r\nvoid mainLoop()\r\n{\r\n\twhile (1)\r\n\t{\r\n\t\tlocalget();\r\n//\t\tsleepMicro(1000000); // Sleep 1s\r\n\t}\r\n}\r\n\r\nint main(int argc, char* argv[])\r\n{\r\n\tnode.ip=\"127.0.0.1:16664\";\r\n\tnode.client_connected=0;\r\n\tnode.client = UA_Client_new(UA_ClientConfig_standard, core_Logger);\r\n\tnode.rReq = new UA_ReadRequest;\r\n\tUA_ReadRequest_init(node.rReq);\r\n\tnode.rReq->nodesToRead = (UA_ReadValueId *)UA_Array_new(&UA_TYPES[UA_TYPES_READVALUEID], 1);\r\n\tnode.rReq->nodesToReadSize = 1;\r\n\tnode.rReq->nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(3, \"DEMO.statepath.alarm.SourceName\"); // assume this node exists\r\n\r\n\tmainLoop();\r\n\treturn 0;\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/acplt/open62541/issues/comments/135668438","html_url":"https://github.com/acplt/open62541/issues/348#issuecomment-135668438","issue_url":"https://api.github.com/repos/acplt/open62541/issues/348","id":135668438,"user":{"login":"Stasik0","id":469170,"avatar_url":"https://avatars.githubusercontent.com/u/469170?v=3","gravatar_id":"","url":"https://api.github.com/users/Stasik0","html_url":"https://github.com/Stasik0","followers_url":"https://api.github.com/users/Stasik0/followers","following_url":"https://api.github.com/users/Stasik0/following{/other_user}","gists_url":"https://api.github.com/users/Stasik0/gists{/gist_id}","starred_url":"https://api.github.com/users/Stasik0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stasik0/subscriptions","organizations_url":"https://api.github.com/users/Stasik0/orgs","repos_url":"https://api.github.com/users/Stasik0/repos","events_url":"https://api.github.com/users/Stasik0/events{/privacy}","received_events_url":"https://api.github.com/users/Stasik0/received_events","type":"User","site_admin":false},"created_at":"2015-08-28T08:14:29Z","updated_at":"2015-08-28T08:14:29Z","body":"@tpiat, please write function names, please use pastebin.com\r\n\r\nplease feel free to test http://open62541.org/releases/0b8d8d566e.zip probably it should also work for your code."}}