{"id":2710,"date":"2025-06-03T10:09:20","date_gmt":"2025-06-03T08:09:20","guid":{"rendered":"https:\/\/www.basyskom.de\/?p=2710"},"modified":"2025-06-03T10:16:57","modified_gmt":"2025-06-03T08:16:57","slug":"open62541-memory-management-essentials","status":"publish","type":"post","link":"https:\/\/www.basyskom.de\/en\/open62541-memory-management-essentials\/","title":{"rendered":"open62541\u200b: memory management essentials"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"2710\" class=\"elementor elementor-2710\" data-elementor-post-type=\"post\">\n\t\t\t\t<div class=\"elementor-element elementor-element-e8aa9f7 e-flex e-con-boxed wpr-particle-no wpr-jarallax-no wpr-parallax-no wpr-sticky-section-no wpr-column-slider-no wpr-equal-height-no e-con e-parent\" data-id=\"e8aa9f7\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-b142520 elementor-widget elementor-widget-heading\" data-id=\"b142520\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">A Leaky Example<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3ddd639 elementor-widget elementor-widget-text-editor\" data-id=\"3ddd639\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>The following OPC UA client example connects to a server, writes the value attribute of a string variable node, reads the value back from the server and then closes the connection.<\/p><ul><li>The <i>client<\/i> and the UA_String <i>payload<\/i> are allocated on the heap.<\/li><li>The UA_NodeId id exists on the stack but contains pointers to memory on the heap allocated by UA_NODEID_STRING_ALLOC.<\/li><li>The UA_Variant myVariant exists on the stack but contains pointers to memory on the heap. UA_Variant_setScalar() attaches the value of <i>payload <\/i>to the variant. After the call to UA_Client_readValueAttribute, the value is replaced by the read result which is again allocated on the heap.<\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3da6e33 elementor-widget elementor-widget-text-editor\" data-id=\"3da6e33\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>For developers coming from C++, the C-style API of\u00a0<a href=\"https:\/\/open62541.org\/\" target=\"_blank\" rel=\"noopener\">open62541<\/a>\u00a0can be very confusing at first. The most confusing part is the memory management because there are lots of ways to create memory leaks.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-95443c0 elementor-widget elementor-widget-elementor-syntax-highlighter\" data-id=\"95443c0\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"elementor-syntax-highlighter.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre><code class='language-cpp'>#include &lt;open62541\/client_config_default.h&gt;\n#include &lt;open62541\/client_highlevel.h&gt;\n\n#include &lt;QDebug&gt;\n\nint main()\n{\n    UA_Client *client = UA_Client_new();\n    UA_ClientConfig *config = UA_Client_getConfig(client);\n\n    UA_ClientConfig_setDefault(config);\n\n    UA_StatusCode result = UA_Client_connect(client, &quot;opc.tcp:\/\/localhost:4840&quot;);\n\n    qDebug() &lt;&lt; &quot;Status code from connect:&quot; &lt;&lt; UA_StatusCode_name(result);\n\n    UA_NodeId id = UA_NODEID_STRING_ALLOC(2, &quot;Demo.Static.Scalar.String&quot;);\n\n    UA_Variant myVariant;\n    UA_Variant_init(&amp;myVariant);\n\n    UA_String *payload = UA_String_new();\n    *payload = UA_STRING_ALLOC(&quot;MyTestValue&quot;);\n    UA_Variant_setScalar(&amp;myVariant, payload, &amp;UA_TYPES[UA_TYPES_STRING]);\n\n    result = UA_Client_writeValueAttribute(client, id, &amp;myVariant);\n\n    qDebug() &lt;&lt; &quot;Status code from write:&quot; &lt;&lt; UA_StatusCode_name(result);\n\n    result = UA_Client_readValueAttribute(client, id, &amp;myVariant);\n\n    qDebug() &lt;&lt; &quot;Status code from read:&quot; &lt;&lt; UA_StatusCode_name(result);\n\n    if (myVariant.data &amp;&amp; myVariant.data != UA_EMPTY_ARRAY_SENTINEL) {\n        UA_String *data = static_cast&lt;UA_String *&gt;(myVariant.data);\n        const QString qStringValue = QString::fromUtf8(reinterpret_cast&lt;char *&gt;(data-&gt;data), data-&gt;length);\n\n        qDebug() &lt;&lt; &quot;Value from server:&quot; &lt;&lt; qStringValue;\n    } else {\n        qDebug() &lt;&lt; &quot;Empty value read from server&quot;;\n    }\n\n    result = UA_Client_disconnect(client);\n\n    qDebug() &lt;&lt; &quot;Status code from disconnect:&quot; &lt;&lt; UA_StatusCode_name(result);\n\n    return result;\n} <\/code><\/pre><script>\nif (!document.getElementById('syntaxed-prism')) {\n\tvar my_awesome_script = document.createElement('script');\n\tmy_awesome_script.setAttribute('src','https:\/\/www.basyskom.de\/wp-content\/plugins\/syntax-highlighter-for-elementor\/assets\/prism2.js');\n\tmy_awesome_script.setAttribute('id','syntaxed-prism');\n\tdocument.body.appendChild(my_awesome_script);\n} else {\n\twindow.Prism && Prism.highlightAll();\n}\n<\/script>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-6955c6d e-flex e-con-boxed wpr-particle-no wpr-jarallax-no wpr-parallax-no wpr-sticky-section-no wpr-column-slider-no wpr-equal-height-no e-con e-parent\" data-id=\"6955c6d\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-4d24850 elementor-widget elementor-widget-heading\" data-id=\"4d24850\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">The Address Sanitizer<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-625c80f elementor-widget elementor-widget-text-editor\" data-id=\"625c80f\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div>The\u00a0<a style=\"background-color: #ffffff;\" href=\"https:\/\/github.com\/google\/sanitizers\/wiki\/AddressSanitizer\" target=\"_blank\" rel=\"noopener\">address sanitizer<\/a>\u00a0is the developer&#8217;s best friend for writing memory leak free code with the open62541 library. It can be activated in gcc\/g++ and clang by adding the flag <b>-fsanitize=address<\/b> and adding <b>-lasan<\/b> to the linker flags.<\/div><div>Let&#8217;s run the code above with address sanitizer to see the memory leaks in our application.<\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-8bb2a77 e-flex e-con-boxed wpr-particle-no wpr-jarallax-no wpr-parallax-no wpr-sticky-section-no wpr-column-slider-no wpr-equal-height-no e-con e-parent\" data-id=\"8bb2a77\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-135b241 elementor-widget elementor-widget-heading\" data-id=\"135b241\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">The Memory Management API<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5478826 elementor-widget elementor-widget-text-editor\" data-id=\"5478826\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div>Open62541 offers a memory management API for all handwritten and generated types. For every type, there are the following functions (example UA_String)<\/div><div>\u00a0<\/div><ul><li>UA_String_new() generates a new instance on the heap<\/li><li>UA_String_delete() frees an instance on the heap and all memory referenced by it.<\/li><li>UA_String_init() initializes all values to zero. This is important for structs on the stack to make sure there are no random pointer values when clearing the struct.<\/li><li>UA_String_clear() \/ UA_String_deleteMembers() deletes all memory allocated\u00a0 on the heap that it referenced by a struct and initializes all values to zero.<\/li><\/ul><div>\u00a0<\/div><p>There are also generic functions which take the type as additional parameter<\/p><ul><li>UA_new(&amp;UA_TYPES[UA_TYPES_STRING])<\/li><li>UA_delete(value, &amp;UA_TYPES[UA_TYPES_STRING])<\/li><li>UA_clear(value, &amp;UA_TYPES[UA_TYPES_STRING])<\/li><\/ul><div>\u00a0<\/div><p>And functions for array handling<\/p><ul><li>UA_Array_new(length, &amp;UA_TYPES[UA_TYPES_STRING])<\/li><li>UA_Array_delete(value, length, &amp;UA_TYPES[UA_TYPES_STRING])<\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-2efee9f e-flex e-con-boxed wpr-particle-no wpr-jarallax-no wpr-parallax-no wpr-sticky-section-no wpr-column-slider-no wpr-equal-height-no e-con e-parent\" data-id=\"2efee9f\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-2c38522 elementor-widget elementor-widget-heading\" data-id=\"2c38522\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Cleanup For The Example Code<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e86bab0 elementor-widget elementor-widget-text-editor\" data-id=\"e86bab0\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>The first leak indicated by the address sanitizer is the string part of the UA_NodeId\u00a0<em>id<\/em>\u00a0which has been allocated on the heap and must be freed<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e920c08 elementor-widget elementor-widget-elementor-syntax-highlighter\" data-id=\"e920c08\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"elementor-syntax-highlighter.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre><code class='language-solid'>Status code from connect: Good\nStatus code from write: Good\nStatus code from read: Good\nValue from server: &quot;MyTestValue&quot;\nStatus code from disconnect: Good\n\n=================================================================\n==19091==ERROR: LeakSanitizer: detected memory leaks\n\nDirect leak of 25 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd9c7 in malloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:69\n    #1 0x7de0d802cefa in UA_String_fromChars ..\/open62541\/src\/ua_types.c:125\n    #2 0x63f35b5fd78b in UA_NODEID_STRING_ALLOC ..\/include\/open62541\/types.h:447\n    #3 0x63f35b5fdecc in main ..\/main.cpp:18\n    #4 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #5 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #6 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nDirect leak of 16 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd340 in calloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:77\n    #1 0x7de0d80300db in UA_new ..\/open62541\/src\/ua_types.c:1210\n    #2 0x7de0d8035cd9 in Variant_decodeBinary ..\/open62541\/src\/ua_types_encoding_binary.c:1194\n    #3 0x7de0d8036247 in DataValue_decodeBinary ..\/open62541\/src\/ua_types_encoding_binary.c:1278\n    #4 0x7de0d80338da in Array_decodeBinary ..\/open62541\/src\/ua_types_encoding_binary.c:501\n    #5 0x7de0d803743d in decodeBinaryStructure ..\/open62541\/src\/ua_types_encoding_binary.c:1682\n    #6 0x7de0d8037a37 in UA_decodeBinaryInternal ..\/open62541\/src\/ua_types_encoding_binary.c:1833\n    #7 0x7de0d80a782d in processMSGResponse ..\/open62541\/src\/client\/ua_client.c:452\n    #8 0x7de0d80a7d4a in processServiceResponse ..\/open62541\/src\/client\/ua_client.c:544\n    #9 0x7de0d80ad8bb in __Client_networkCallback ..\/open62541\/src\/client\/ua_client_connect.c:1600\n    #10 0x7de0d820248d in TCP_connectionSocketCallback ..\/open62541\/arch\/eventloop_posix_tcp.c:220\n    #11 0x7de0d8201632 in UA_EventLoopPOSIX_pollFDs ..\/open62541\/arch\/eventloop_posix_epoll.c:123\n    #12 0x7de0d8200787 in UA_EventLoopPOSIX_run ..\/open62541\/arch\/eventloop_posix.c:279\n    #13 0x7de0d80a8087 in __Client_Service ..\/open62541\/src\/client\/ua_client.c:626\n    #14 0x7de0d80a81c9 in __UA_Client_Service ..\/open62541\/src\/client\/ua_client.c:672\n    #15 0x7de0d80b0fe9 in UA_Client_Service_read ..\/open62541\/include\/open62541\/client.h:614\n    #16 0x7de0d80b3649 in __UA_Client_readAttribute ..\/open62541\/src\/client\/ua_client_highlevel.c:372\n    #17 0x63f35b5fd9ae in UA_Client_readValueAttribute ..\/include\/open62541\/client_highlevel.h:143\n    #18 0x63f35b5fe19d in main ..\/main.cpp:31\n    #19 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #20 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #21 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nDirect leak of 16 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd340 in calloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:77\n    #1 0x7de0d80300db in UA_new ..\/open62541\/src\/ua_types.c:1210\n    #2 0x63f35b5fd7b0 in UA_String_new ..\/include\/open62541\/types_generated_handling.h:423\n    #3 0x63f35b5fdefd in main ..\/main.cpp:23\n    #4 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #5 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #6 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 131072 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd9c7 in malloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:69\n    #1 0x7de0d802d8ae in UA_ByteString_allocBuffer ..\/open62541\/src\/ua_types.c:309\n    #2 0x7de0d8200dff in UA_EventLoopPOSIX_allocateRXBuffer ..\/open62541\/arch\/eventloop_posix.c:511\n    #3 0x7de0d82085ee in UDP_eventSourceStart ..\/open62541\/arch\/eventloop_posix_udp.c:1311\n    #4 0x7de0d82003ed in UA_EventLoopPOSIX_start ..\/open62541\/arch\/eventloop_posix.c:149\n    #5 0x7de0d80a9037 in __UA_Client_startup ..\/open62541\/src\/client\/ua_client.c:1035\n    #6 0x7de0d80adbfa in initConnect ..\/open62541\/src\/client\/ua_client_connect.c:1684\n    #7 0x7de0d80ae0c1 in connectSync ..\/open62541\/src\/client\/ua_client_connect.c:1768\n    #8 0x7de0d80ae25e in connectInternal ..\/open62541\/src\/client\/ua_client_connect.c:1816\n    #9 0x7de0d80ae337 in __UA_Client_connect ..\/open62541\/src\/client\/ua_client_connect.c:1835\n    #10 0x63f35b5fd8c6 in UA_Client_connect ..\/include\/open62541\/client.h:378\n    #11 0x63f35b5fdd63 in main ..\/main.cpp:14\n    #12 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #13 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #14 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 131072 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd9c7 in malloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:69\n    #1 0x7de0d802d8ae in UA_ByteString_allocBuffer ..\/open62541\/src\/ua_types.c:309\n    #2 0x7de0d8200dff in UA_EventLoopPOSIX_allocateRXBuffer ..\/open62541\/arch\/eventloop_posix.c:511\n    #3 0x7de0d82048ba in TCP_eventSourceStart ..\/open62541\/arch\/eventloop_posix_tcp.c:989\n    #4 0x7de0d82003ed in UA_EventLoopPOSIX_start ..\/open62541\/arch\/eventloop_posix.c:149\n    #5 0x7de0d80a9037 in __UA_Client_startup ..\/open62541\/src\/client\/ua_client.c:1035\n    #6 0x7de0d80adbfa in initConnect ..\/open62541\/src\/client\/ua_client_connect.c:1684\n    #7 0x7de0d80ae0c1 in connectSync ..\/open62541\/src\/client\/ua_client_connect.c:1768\n    #8 0x7de0d80ae25e in connectInternal ..\/open62541\/src\/client\/ua_client_connect.c:1816\n    #9 0x7de0d80ae337 in __UA_Client_connect ..\/open62541\/src\/client\/ua_client_connect.c:1835\n    #10 0x63f35b5fd8c6 in UA_Client_connect ..\/include\/open62541\/client.h:378\n    #11 0x63f35b5fdd63 in main ..\/main.cpp:14\n    #12 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #13 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #14 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 1712 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd9c7 in malloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:69\n    #1 0x7de0d80a6a33 in UA_Client_newWithConfig ..\/open62541\/src\/client\/ua_client.c:110\n    #2 0x7de0d81f40e6 in UA_Client_new ..\/open62541\/plugins\/ua_config_default.c:1094\n    #3 0x63f35b5fdd1e in main ..\/main.cpp:9\n    #4 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #5 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #6 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 320 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd340 in calloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:77\n    #1 0x7de0d8200b6c in UA_EventLoop_new_POSIX ..\/open62541\/arch\/eventloop_posix.c:435\n    #2 0x7de0d81f4182 in UA_ClientConfig_setDefault ..\/open62541\/plugins\/ua_config_default.c:1125\n    #3 0x7de0d81f40c1 in UA_Client_new ..\/open62541\/plugins\/ua_config_default.c:1091\n    #4 0x63f35b5fdd1e in main ..\/main.cpp:9\n    #5 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #6 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #7 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 176 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd340 in calloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:77\n    #1 0x7de0d8204a8c in UA_ConnectionManager_new_POSIX_TCP ..\/open62541\/arch\/eventloop_posix_tcp.c:1053\n    #2 0x7de0d81f41c4 in UA_ClientConfig_setDefault ..\/open62541\/plugins\/ua_config_default.c:1130\n    #3 0x7de0d81f40c1 in UA_Client_new ..\/open62541\/plugins\/ua_config_default.c:1091\n    #4 0x63f35b5fdd1e in main ..\/main.cpp:9\n    #5 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #6 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #7 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 176 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd340 in calloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:77\n    #1 0x7de0d82087c0 in UA_ConnectionManager_new_POSIX_UDP ..\/open62541\/arch\/eventloop_posix_udp.c:1375\n    #2 0x7de0d81f421d in UA_ClientConfig_setDefault ..\/open62541\/plugins\/ua_config_default.c:1135\n    #3 0x7de0d81f40c1 in UA_Client_new ..\/open62541\/plugins\/ua_config_default.c:1091\n    #4 0x63f35b5fdd1e in main ..\/main.cpp:9\n    #5 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #6 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #7 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 88 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd9c7 in malloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:69\n    #1 0x7de0d81feda4 in addCallback ..\/open62541\/arch\/common\/ua_timer.c:61\n    #2 0x7de0d81feffa in UA_Timer_addRepeatedCallback ..\/open62541\/arch\/common\/ua_timer.c:121\n    #3 0x7de0d820006f in UA_EventLoopPOSIX_addCyclicCallback ..\/open62541\/arch\/eventloop_posix.c:42\n    #4 0x7de0d80a8ff0 in __UA_Client_startup ..\/open62541\/src\/client\/ua_client.c:1026\n    #5 0x7de0d80adbfa in initConnect ..\/open62541\/src\/client\/ua_client_connect.c:1684\n    #6 0x7de0d80ae0c1 in connectSync ..\/open62541\/src\/client\/ua_client_connect.c:1768\n    #7 0x7de0d80ae25e in connectInternal ..\/open62541\/src\/client\/ua_client_connect.c:1816\n    #8 0x7de0d80ae337 in __UA_Client_connect ..\/open62541\/src\/client\/ua_client_connect.c:1835\n    #9 0x63f35b5fd8c6 in UA_Client_connect ..\/include\/open62541\/client.h:378\n    #10 0x63f35b5fdd63 in main ..\/main.cpp:14\n    #11 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #12 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #13 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 32 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd340 in calloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:77\n    #1 0x7de0d8033793 in Array_decodeBinary ..\/open62541\/src\/ua_types_encoding_binary.c:488\n    #2 0x7de0d80339f9 in String_decodeBinary ..\/open62541\/src\/ua_types_encoding_binary.c:520\n    #3 0x7de0d8037478 in decodeBinaryStructure ..\/open62541\/src\/ua_types_encoding_binary.c:1688\n    #4 0x7de0d8037a37 in UA_decodeBinaryInternal ..\/open62541\/src\/ua_types_encoding_binary.c:1833\n    #5 0x7de0d80a782d in processMSGResponse ..\/open62541\/src\/client\/ua_client.c:452\n    #6 0x7de0d80a7d4a in processServiceResponse ..\/open62541\/src\/client\/ua_client.c:544\n    #7 0x7de0d80ad8bb in __Client_networkCallback ..\/open62541\/src\/client\/ua_client_connect.c:1600\n    #8 0x7de0d820248d in TCP_connectionSocketCallback ..\/open62541\/arch\/eventloop_posix_tcp.c:220\n    #9 0x7de0d8201632 in UA_EventLoopPOSIX_pollFDs ..\/open62541\/arch\/eventloop_posix_epoll.c:123\n    #10 0x7de0d8200787 in UA_EventLoopPOSIX_run ..\/open62541\/arch\/eventloop_posix.c:279\n    #11 0x7de0d80ae1ac in connectSync ..\/open62541\/src\/client\/ua_client_connect.c:1795\n    #12 0x7de0d80ae25e in connectInternal ..\/open62541\/src\/client\/ua_client_connect.c:1816\n    #13 0x7de0d80ae337 in __UA_Client_connect ..\/open62541\/src\/client\/ua_client_connect.c:1835\n    #14 0x63f35b5fd8c6 in UA_Client_connect ..\/include\/open62541\/client.h:378\n    #15 0x63f35b5fdd63 in main ..\/main.cpp:14\n    #16 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #17 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #18 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 28 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd9c7 in malloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:69\n    #1 0x7de0d802cefa in UA_String_fromChars ..\/open62541\/src\/ua_types.c:125\n    #2 0x7de0d81f431f in UA_ClientConfig_setDefault ..\/open62541\/plugins\/ua_config_default.c:1155\n    #3 0x7de0d81f40c1 in UA_Client_new ..\/open62541\/plugins\/ua_config_default.c:1091\n    #4 0x63f35b5fdd1e in main ..\/main.cpp:9\n    #5 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #6 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #7 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 25 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd9c7 in malloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:69\n    #1 0x7de0d802cefa in UA_String_fromChars ..\/open62541\/src\/ua_types.c:125\n    #2 0x63f35b5fd8a7 in UA_Client_connect ..\/include\/open62541\/client.h:375\n    #3 0x63f35b5fdd63 in main ..\/main.cpp:14\n    #4 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #5 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #6 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 22 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd340 in calloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:77\n    #1 0x7de0d803227d in UA_Array_copy ..\/open62541\/src\/ua_types.c:1962\n    #2 0x7de0d802d13c in String_copy ..\/open62541\/src\/ua_types.c:172\n    #3 0x7de0d80305e2 in UA_copy ..\/open62541\/src\/ua_types.c:1373\n    #4 0x7de0d8204d39 in UA_String_copy ..\/open62541\/build\/src_generated\/open62541\/types_generated_handling.h:428\n    #5 0x7de0d82087f7 in UA_ConnectionManager_new_POSIX_UDP ..\/open62541\/arch\/eventloop_posix_udp.c:1380\n    #6 0x7de0d81f421d in UA_ClientConfig_setDefault ..\/open62541\/plugins\/ua_config_default.c:1135\n    #7 0x7de0d81f40c1 in UA_Client_new ..\/open62541\/plugins\/ua_config_default.c:1091\n    #8 0x63f35b5fdd1e in main ..\/main.cpp:9\n    #9 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #10 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #11 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 22 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd340 in calloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:77\n    #1 0x7de0d803227d in UA_Array_copy ..\/open62541\/src\/ua_types.c:1962\n    #2 0x7de0d802d13c in String_copy ..\/open62541\/src\/ua_types.c:172\n    #3 0x7de0d80305e2 in UA_copy ..\/open62541\/src\/ua_types.c:1373\n    #4 0x7de0d820183c in UA_String_copy ..\/open62541\/build\/src_generated\/open62541\/types_generated_handling.h:428\n    #5 0x7de0d8204ac3 in UA_ConnectionManager_new_POSIX_TCP ..\/open62541\/arch\/eventloop_posix_tcp.c:1058\n    #6 0x7de0d81f41c4 in UA_ClientConfig_setDefault ..\/open62541\/plugins\/ua_config_default.c:1130\n    #7 0x7de0d81f40c1 in UA_Client_new ..\/open62541\/plugins\/ua_config_default.c:1091\n    #8 0x63f35b5fdd1e in main ..\/main.cpp:9\n    #9 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #10 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #11 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 11 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd340 in calloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:77\n    #1 0x7de0d8033793 in Array_decodeBinary ..\/open62541\/src\/ua_types_encoding_binary.c:488\n    #2 0x7de0d80339f9 in String_decodeBinary ..\/open62541\/src\/ua_types_encoding_binary.c:520\n    #3 0x7de0d8035d51 in Variant_decodeBinary ..\/open62541\/src\/ua_types_encoding_binary.c:1196\n    #4 0x7de0d8036247 in DataValue_decodeBinary ..\/open62541\/src\/ua_types_encoding_binary.c:1278\n    #5 0x7de0d80338da in Array_decodeBinary ..\/open62541\/src\/ua_types_encoding_binary.c:501\n    #6 0x7de0d803743d in decodeBinaryStructure ..\/open62541\/src\/ua_types_encoding_binary.c:1682\n    #7 0x7de0d8037a37 in UA_decodeBinaryInternal ..\/open62541\/src\/ua_types_encoding_binary.c:1833\n    #8 0x7de0d80a782d in processMSGResponse ..\/open62541\/src\/client\/ua_client.c:452\n    #9 0x7de0d80a7d4a in processServiceResponse ..\/open62541\/src\/client\/ua_client.c:544\n    #10 0x7de0d80ad8bb in __Client_networkCallback ..\/open62541\/src\/client\/ua_client_connect.c:1600\n    #11 0x7de0d820248d in TCP_connectionSocketCallback ..\/open62541\/arch\/eventloop_posix_tcp.c:220\n    #12 0x7de0d8201632 in UA_EventLoopPOSIX_pollFDs ..\/open62541\/arch\/eventloop_posix_epoll.c:123\n    #13 0x7de0d8200787 in UA_EventLoopPOSIX_run ..\/open62541\/arch\/eventloop_posix.c:279\n    #14 0x7de0d80a8087 in __Client_Service ..\/open62541\/src\/client\/ua_client.c:626\n    #15 0x7de0d80a81c9 in __UA_Client_Service ..\/open62541\/src\/client\/ua_client.c:672\n    #16 0x7de0d80b0fe9 in UA_Client_Service_read ..\/open62541\/include\/open62541\/client.h:614\n    #17 0x7de0d80b3649 in __UA_Client_readAttribute ..\/open62541\/src\/client\/ua_client_highlevel.c:372\n    #18 0x63f35b5fd9ae in UA_Client_readValueAttribute ..\/include\/open62541\/client_highlevel.h:143\n    #19 0x63f35b5fe19d in main ..\/main.cpp:31\n    #20 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #21 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #22 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nIndirect leak of 11 byte(s) in 1 object(s) allocated from:\n    #0 0x7de0d8afd9c7 in malloc ..\/..\/..\/..\/src\/libsanitizer\/asan\/asan_malloc_linux.cpp:69\n    #1 0x7de0d802cefa in UA_String_fromChars ..\/open62541\/src\/ua_types.c:125\n    #2 0x63f35b5fdf38 in main ..\/main.cpp:24\n    #3 0x7de0d782a1c9 in __libc_start_call_main ..\/sysdeps\/nptl\/libc_start_call_main.h:58\n    #4 0x7de0d782a28a in __libc_start_main_impl ..\/csu\/libc-start.c:360\n    #5 0x63f35b5fd5e4 in _start (..\/opc_client+0x25e4) (BuildId: 1b68253fabe238958b36c865c935f90d2b3095d8)\n\nSUMMARY: AddressSanitizer: 264824 byte(s) leaked in 17 allocation(s). <\/code><\/pre><script>\nif (!document.getElementById('syntaxed-prism')) {\n\tvar my_awesome_script = document.createElement('script');\n\tmy_awesome_script.setAttribute('src','https:\/\/www.basyskom.de\/wp-content\/plugins\/syntax-highlighter-for-elementor\/assets\/prism2.js');\n\tmy_awesome_script.setAttribute('id','syntaxed-prism');\n\tdocument.body.appendChild(my_awesome_script);\n} else {\n\twindow.Prism && Prism.highlightAll();\n}\n<\/script>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8894a22 elementor-widget elementor-widget-elementor-syntax-highlighter\" data-id=\"8894a22\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"elementor-syntax-highlighter.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre><code class='language-cpp'>UA_NodeId_clear(&amp;id); <\/code><\/pre><script>\nif (!document.getElementById('syntaxed-prism')) {\n\tvar my_awesome_script = document.createElement('script');\n\tmy_awesome_script.setAttribute('src','https:\/\/www.basyskom.de\/wp-content\/plugins\/syntax-highlighter-for-elementor\/assets\/prism2.js');\n\tmy_awesome_script.setAttribute('id','syntaxed-prism');\n\tdocument.body.appendChild(my_awesome_script);\n} else {\n\twindow.Prism && Prism.highlightAll();\n}\n<\/script>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-662c8d3 elementor-widget elementor-widget-text-editor\" data-id=\"662c8d3\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>The second leak is the value read from the server by UA_Client_readValueAttribute(). It is also the responsibility of the user to free values the library has attached to a struct passed as output parameter in a function call like UA_Client_readValueAttribute().<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-193b6ce elementor-widget elementor-widget-elementor-syntax-highlighter\" data-id=\"193b6ce\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"elementor-syntax-highlighter.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre><code class='language-cpp'>UA_Variant_clear(&amp;myVariant); <\/code><\/pre><script>\nif (!document.getElementById('syntaxed-prism')) {\n\tvar my_awesome_script = document.createElement('script');\n\tmy_awesome_script.setAttribute('src','https:\/\/www.basyskom.de\/wp-content\/plugins\/syntax-highlighter-for-elementor\/assets\/prism2.js');\n\tmy_awesome_script.setAttribute('id','syntaxed-prism');\n\tdocument.body.appendChild(my_awesome_script);\n} else {\n\twindow.Prism && Prism.highlightAll();\n}\n<\/script>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-126a92b elementor-widget elementor-widget-text-editor\" data-id=\"126a92b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>The third leak is the UA_String <i>payload<\/i> which has been allocated on the heap via UA_String_new(). It has been created by the user and must be freed by the user.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a670b59 elementor-widget elementor-widget-elementor-syntax-highlighter\" data-id=\"a670b59\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"elementor-syntax-highlighter.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre><code class='language-cpp'>UA_String_delete(payload); <\/code><\/pre><script>\nif (!document.getElementById('syntaxed-prism')) {\n\tvar my_awesome_script = document.createElement('script');\n\tmy_awesome_script.setAttribute('src','https:\/\/www.basyskom.de\/wp-content\/plugins\/syntax-highlighter-for-elementor\/assets\/prism2.js');\n\tmy_awesome_script.setAttribute('id','syntaxed-prism');\n\tdocument.body.appendChild(my_awesome_script);\n} else {\n\twindow.Prism && Prism.highlightAll();\n}\n<\/script>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f124fa0 elementor-widget elementor-widget-text-editor\" data-id=\"f124fa0\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>The first indirect leak is the UA_Client <em>client<\/em>\u00a0that has been created using UA_Client_new(). It must also be freed by the user.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-843740b elementor-widget elementor-widget-elementor-syntax-highlighter\" data-id=\"843740b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"elementor-syntax-highlighter.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre><code class='language-cpp'>UA_Client_delete(client); <\/code><\/pre><script>\nif (!document.getElementById('syntaxed-prism')) {\n\tvar my_awesome_script = document.createElement('script');\n\tmy_awesome_script.setAttribute('src','https:\/\/www.basyskom.de\/wp-content\/plugins\/syntax-highlighter-for-elementor\/assets\/prism2.js');\n\tmy_awesome_script.setAttribute('id','syntaxed-prism');\n\tdocument.body.appendChild(my_awesome_script);\n} else {\n\twindow.Prism && Prism.highlightAll();\n}\n<\/script>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-8e593bb e-flex e-con-boxed wpr-particle-no wpr-jarallax-no wpr-parallax-no wpr-sticky-section-no wpr-column-slider-no wpr-equal-height-no e-con e-parent\" data-id=\"8e593bb\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-ab9f27d elementor-widget elementor-widget-heading\" data-id=\"ab9f27d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Final Leak-free Example<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-60df698 elementor-widget elementor-widget-text-editor\" data-id=\"60df698\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div>By adding these four lines to the code, all memory is cleaned up correctly and the additional indirect leaks disappear.<\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8623db1 elementor-widget elementor-widget-elementor-syntax-highlighter\" data-id=\"8623db1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"elementor-syntax-highlighter.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre><code class='language-cpp'>#include &lt;open62541\/client_config_default.h&gt;\n#include &lt;open62541\/client_highlevel.h&gt;\n\n#include &lt;QDebug&gt;\n\nint main()\n{\n    UA_Client *client = UA_Client_new();\n    UA_ClientConfig *config = UA_Client_getConfig(client);\n\n    UA_ClientConfig_setDefault(config);\n\n    UA_StatusCode result = UA_Client_connect(client, &quot;opc.tcp:\/\/localhost:4840&quot;);\n\n    qDebug() &lt;&lt; &quot;Status code from connect:&quot; &lt;&lt; UA_StatusCode_name(result);\n\n    UA_NodeId id = UA_NODEID_STRING_ALLOC(2, &quot;Demo.Static.Scalar.String&quot;);\n\n    UA_Variant myVariant;\n    UA_Variant_init(&amp;myVariant);\n\n    UA_String *payload = UA_String_new();\n    *payload = UA_STRING_ALLOC(&quot;MyTestValue&quot;);\n    UA_Variant_setScalar(&amp;myVariant, payload, &amp;UA_TYPES[UA_TYPES_STRING]);\n\n    result = UA_Client_writeValueAttribute(client, id, &amp;myVariant);\n\n    qDebug() &lt;&lt; &quot;Status code from write:&quot; &lt;&lt; UA_StatusCode_name(result);\n\n    result = UA_Client_readValueAttribute(client, id, &amp;myVariant);\n\n    qDebug() &lt;&lt; &quot;Status code from read:&quot; &lt;&lt; UA_StatusCode_name(result);\n\n    if (myVariant.data &amp;&amp; myVariant.data != UA_EMPTY_ARRAY_SENTINEL) {\n        UA_String *data = static_cast&lt;UA_String *&gt;(myVariant.data);\n        const QString qStringValue = QString::fromUtf8(reinterpret_cast&lt;char *&gt;(data-&gt;data), data-&gt;length);\n\n        qDebug() &lt;&lt; &quot;Value from server:&quot; &lt;&lt; qStringValue;\n    } else {\n        qDebug() &lt;&lt; &quot;Empty value read from server&quot;;\n    }\n\n    result = UA_Client_disconnect(client);\n\n    qDebug() &lt;&lt; &quot;Status code from disconnect:&quot; &lt;&lt; UA_StatusCode_name(result);\n\n    UA_NodeId_clear(&amp;id);\n    UA_Variant_clear(&amp;myVariant);\n    UA_String_delete(payload);\n    UA_Client_delete(client);\n\n    return result;\n}\n <\/code><\/pre><script>\nif (!document.getElementById('syntaxed-prism')) {\n\tvar my_awesome_script = document.createElement('script');\n\tmy_awesome_script.setAttribute('src','https:\/\/www.basyskom.de\/wp-content\/plugins\/syntax-highlighter-for-elementor\/assets\/prism2.js');\n\tmy_awesome_script.setAttribute('id','syntaxed-prism');\n\tdocument.body.appendChild(my_awesome_script);\n} else {\n\twindow.Prism && Prism.highlightAll();\n}\n<\/script>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-e853c08 e-flex e-con-boxed wpr-particle-no wpr-jarallax-no wpr-parallax-no wpr-sticky-section-no wpr-column-slider-no wpr-equal-height-no e-con e-parent\" data-id=\"e853c08\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-e53cc51 elementor-widget elementor-widget-heading\" data-id=\"e53cc51\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Conclusion: Memory Management With open62541<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4719b7b elementor-widget elementor-widget-text-editor\" data-id=\"4719b7b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ul><li>Free everything you have directly allocated on the heap with UA_{type}_new() via UA_{type}_delete()<\/li><li>Initialize all structs on the stack with UA_{type}_init() before using them<\/li><li>Clear all structs on the stack via UA_{type}_clear() before discarding or overwriting them<\/li><li><strong>Always use the address sanitizer, even if you know what you are doing<\/strong><\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>The C-style API of open62541 can be confusing, the most confusing part is the memory management because there are lots of ways to create memory leaks. Learn how to avoid these pitfalls.<\/p>","protected":false},"author":4,"featured_media":2400,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1,2,7,183],"tags":[122],"class_list":["post-2710","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-allgemein","category-blog","category-general","category-open62541","tag-open62541"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.basyskom.de\/en\/wp-json\/wp\/v2\/posts\/2710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.basyskom.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.basyskom.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.basyskom.de\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.basyskom.de\/en\/wp-json\/wp\/v2\/comments?post=2710"}],"version-history":[{"count":85,"href":"https:\/\/www.basyskom.de\/en\/wp-json\/wp\/v2\/posts\/2710\/revisions"}],"predecessor-version":[{"id":12014,"href":"https:\/\/www.basyskom.de\/en\/wp-json\/wp\/v2\/posts\/2710\/revisions\/12014"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.basyskom.de\/en\/wp-json\/wp\/v2\/media\/2400"}],"wp:attachment":[{"href":"https:\/\/www.basyskom.de\/en\/wp-json\/wp\/v2\/media?parent=2710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.basyskom.de\/en\/wp-json\/wp\/v2\/categories?post=2710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.basyskom.de\/en\/wp-json\/wp\/v2\/tags?post=2710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}