Resource leak because disposable member objects were not disposed|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Resource leak because disposable member objects were not disposed
Avatar
Mutsumu Nomura
New Member
Members
Forum Posts: 2
Member Since:
10/24/2014
sp_UserOfflineSmall Offline
1
09/27/2018 - 03:24
sp_Permalink sp_Print

I got source code for Opc.Ua.Core and Opc.Ua.Client from Siemens's sample application project.

I was using the DLLs for developing our application in C#, and noticed some resource leak after application running some time.

I tracked to two problems, that ClientBase and TcpChannel class, when disposing themselves does not dispose 

their disposable member (m_channel and m_socket).

I changed the code Stack/Core/Stack/Tcp/TcpChannel line 137

protected virtual void Dispose(bool disposing)
{
    if (disposing)
    {
        // nothing to do.
    }
}

to

protected virtual void Dispose(bool disposing)
{
    if (disposing)
    {
        if (m_socket != null)
        {
            m_socket.Dispose();
        }
    }
}

 

and Stack/Core/Stack/Client/ClientBase.cs line 53

public void Dispose()
{
    Dispose(true);
}

public void Dispose()
{
    if (m_channel != null)
    {
        m_channel.Dispose();
    }
    Dispose(true);
}

And resource leak is eliminated.

Here I saw FAQ about Submitting code, and peeked source on github.

The code for ClientBase was not changed. The file for TcpChannel does not exist any more.

I don't know about newer codebase, so I report here.

 

Best regards

Mutsumu Nomura

Avatar
Randy Armstrong
Admin
Forum Posts: 1457
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
09/27/2018 - 12:38
sp_Permalink sp_Print

Please post these issues on GitHub:

https://github.com/OPCFoundati.....ETStandard

Avatar
Mutsumu Nomura
New Member
Members
Forum Posts: 2
Member Since:
10/24/2014
sp_UserOfflineSmall Offline
3
09/28/2018 - 00:15
sp_Permalink sp_Print

I checked the github source. And it seems the code I got/edited belongs to UA Legacy codebase.

I'm trying with newer UA-.NETStandard, and check if the same problem remains in newer code.

Thank you.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 15
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1353
Posts: 4589