Page 1 of 1

How to delete memory allocated for UaDataValue object

Posted: 28 May 2020, 11:51
by Antoni Raj
Hi Support Team,
We are using Unified Automation UA SDK C++ Server Professional 1.6.3 in our OPC UA server. We use visual studio 2015 for our development.
We are following sample server “server_com_da_migration” for our OPC server development.
We have our own NodeManager implementation.

Below is code snippet in the executeRead() method. This executeRead() method is called every 10 millisecond.
We are afraid that the dataValue of type UaDataValue will cause memoryleak. Because every 10 millisecond one object of type UaDataValue is created.

void OPCUAIOManagerJob::executeRead()

UaDataValue dataValue;




1. How to delete the memory allocated for UaDataValue ? Does it taken care by tool kit.?
2. We tried using dataValue.clear( ) as shown in code snippet. But the read is not successful.

Please help us on this.Thanks in advance for the help.


Re: How to delete memory allocated for UaDataValue object

Posted: 02 Jun 2020, 13:22
by Support Team
Hello Antoni,

in the code you posted you use a local variable dataValue. So the destructor of UaDataValue will be called when execution leaves that scope.
The destructor of UaDataValue clears all resources used by that class. There's no need to explicitly call dataValue.clear() here.

Do you observe any memory leaks or are you just wondering if that could happen?

Re: How to delete memory allocated for UaDataValue object

Posted: 03 Jun 2020, 08:40
by Antoni Raj
Hi Team,
Thank you very much for your quick response . I appreciate it.
No . I am not facing any memory leaks. Just asking for clarification.

Thank you again