You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by "takraj (via GitHub)" <gi...@apache.org> on 2023/09/23 13:20:07 UTC

[I] [Bug]: plc4j-driver-opcua seems to leak memory

takraj opened a new issue, #1101:
URL: https://github.com/apache/plc4x/issues/1101

   ### What happened?
   
   The OPC-UA driver seem to leak memory when closing a connection object. This issue sooner or later lead to application crash with OOM error. Workaround would be to reuse connection objects, but then we face the issue #1100, which I believe renders a fix for this pretty urgent.
   
   ![Screenshot from 2023-09-23 14-14-10](https://github.com/apache/plc4x/assets/2440418/17d5329b-e1ed-459c-bd1f-5d3339b22982)
   
   
   Example code to reproduce the issue:
   ```
   PlcDriverManager driverManager = new PlcDriverManager();
   
   AtomicBoolean running = new AtomicBoolean(true);
   Runtime.getRuntime().addShutdownHook(new Thread(() -> running.set(true)));
   
   while (running.get()) {
       PlcConnection connection = driverManager.getConnection("opcua:tcp://127.0.0.1:40185/milo?discovery=false");
       try {
           Thread.sleep(100);
       } finally {
           connection.close();
       }
   }
   ```
   
   Some additional charts
   --------------------------------
   
   ![Screenshot from 2023-09-23 14-23-14](https://github.com/apache/plc4x/assets/2440418/1384d3d8-63b8-4abb-ac75-4843d9bf72b2)
   
   ![Screenshot from 2023-09-23 14-08-05](https://github.com/apache/plc4x/assets/2440418/0a50afb6-3d8d-436f-afcb-a3bb7253f1f1)
   
   ![Screenshot from 2023-09-23 14-10-16](https://github.com/apache/plc4x/assets/2440418/e98e765c-79a5-40bc-b342-4c4acd9c9337)
   
   ![Screenshot from 2023-09-23 14-10-25](https://github.com/apache/plc4x/assets/2440418/913b2138-0571-4cff-a75b-9ebedebb1f56)
   
   Logs
   --------
   
   [logs-before-oom.txt](https://github.com/apache/plc4x/files/12706498/logs-before-oom.txt)
   
   Heap dumps
   -------------------
   
   * [MemoryLeakDemo_1045304_23_09_2023_12_41_27.zip](https://github.com/apache/plc4x/files/12706514/MemoryLeakDemo_1045304_23_09_2023_12_41_27.zip)
   * [MemoryLeakDemo_1045304_23_09_2023_13_02_21.zip](https://github.com/apache/plc4x/files/12706515/MemoryLeakDemo_1045304_23_09_2023_13_02_21.zip)
   * [MemoryLeakDemo_1045304_23_09_2023_14_05_15.zip](https://github.com/apache/plc4x/files/12706519/MemoryLeakDemo_1045304_23_09_2023_14_05_15.zip)
   
   
   ### Version
   
   v0.10.0
   
   ### Programming Languages
   
   - [X] plc4j
   - [ ] plc4go
   - [ ] plc4c
   - [ ] plc4net
   
   ### Protocols
   
   - [ ] AB-Ethernet
   - [ ] ADS /AMS
   - [ ] BACnet/IP
   - [ ] CANopen
   - [ ] DeltaV
   - [ ] DF1
   - [ ] EtherNet/IP
   - [ ] Firmata
   - [ ] KNXnet/IP
   - [ ] Modbus
   - [X] OPC-UA
   - [ ] S7


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "qtvbwfn (via GitHub)" <gi...@apache.org>.
qtvbwfn commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2051446401

   ![image](https://github.com/apache/plc4x/assets/5848026/17088995-0f28-46a1-80d0-462512ec80db)
   ![image](https://github.com/apache/plc4x/assets/5848026/4524f087-d41c-4a1d-b621-a322f1a89797)
   By testing the latest version and tracking the logs of the OPC UA SERVER, it was found that two connections were created each time, but only one was closed upon termination.
   
   
   @splatch @chrisdutz @takraj @hutcheb 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2051665915

   Yes ... we split up the repo to separate the integration modules, additional tools and examples from the main repository.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1741190498

   And they all seem to be related to the nio event group: 
   
   ![image](https://github.com/apache/plc4x/assets/651105/afe9f0a5-6dba-4e2a-97f6-79715f6c6400)
   
   Hmpf ... I thought we had addressed that issue and I guess it probably also has an effect on all other drivers too ... Usually opening and closing connections shouldn't be the default case, as the connection-cache should be used, but I think having somethign stuck will also be the reason why some applications simply don't stop gracefully.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "splatch (via GitHub)" <gi...@apache.org>.
splatch commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2051452731

   Looks like pre-flight discovery connection might be part of the trouble.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "qtvbwfn (via GitHub)" <gi...@apache.org>.
qtvbwfn commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2051170186

   
   I previously attempted to address this issue on version 0.10.0, where the main problem resided in OpcuaProtocolLogic. It occurred when calling the close method on the PlcConnection, resulting in resources not being properly released. Subsequently, due to significant API changes, I did not pursue further investigation at that time. Since then, for OPCUA handling, I have consistently used the Eclipse Milo client.
   
   @splatch 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "christofe-lintermans-actemium (via GitHub)" <gi...@apache.org>.
christofe-lintermans-actemium commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1873777911

   Hi All,
   
   I have the same issue, but when using Apache NiFi integration.
   
   ![image](https://github.com/apache/plc4x/assets/65465652/1ea8ee3a-10b6-4905-9b15-6107adecf1f8)
   
   Should I create a new issue, or is this issue 1101 sufficient?
   
   Could a priority be assigned to address this issue?
   
   Thank you in advance!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "christofe-lintermans-actemium (via GitHub)" <gi...@apache.org>.
christofe-lintermans-actemium commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2051635202

   @splatch 
   
   Can you guide me on how to build the nar file for NiFi including this fix?  I already checked out the branch locally.
   I can quickly test it on the system.
   
   Thank you in advance.
   
   Christofe


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "christofe-lintermans-actemium (via GitHub)" <gi...@apache.org>.
christofe-lintermans-actemium commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2051663200

   could it be that the integrations is moved to another repo https://github.com/apache/plc4x-extras?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1741240593

   YAY ... I found it :-)
   It wasn#t the event loops .. they are correctly closed.
   It was the NettyHashTimerTimeoutManager that we start for every connection but never explicitly close it ... by overriding the close() method of ChannelDuplexHandler in Plc4xNettyWrapper and explicitly closing it, the leak of open threads is gone ... you can see a commons-pool growing at the start, but as soon as it's reached it's 11 threads the thread-count stays constant :-)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "splatch (via GitHub)" <gi...@apache.org>.
splatch closed issue #1101: [Bug]: plc4j-driver-opcua seems to leak memory
URL: https://github.com/apache/plc4x/issues/1101


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "christofe-lintermans-actemium (via GitHub)" <gi...@apache.org>.
christofe-lintermans-actemium commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2051354331

   > I previously attempted to address this issue on version 0.10.0, where the main problem resided in OpcuaProtocolLogic. It occurred when calling the close method on the PlcConnection, resulting in resources not being properly released. Subsequently, due to significant API changes, I did not pursue further investigation at that time. Since then, for OPCUA handling, I have consistently used the Eclipse Milo client.
   > 
   > @splatch
   
   Thank you for the info.
   PLC4X uses eclipse milo underlying for the OPCUA driver.
   
   ![image](https://github.com/apache/plc4x/assets/65465652/8e0556c8-8f94-41ce-ac18-81e9cdec0dce)
   
   So I want to avoid a proprietary implementation for OPC UA.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1740983366

   I'll have a look at this as it seems none else is currently planning on doing so ... hopefully this doesn't require too much knowledge of the OPC-UA protocol.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1741164428

   Ok ... after running it for almost two hours ... there's definitely something going on ... not sure if it's because I'm also running the server in the same VM ... It's consuming quite a bit more Memory and a lot more CPU time.
   ![image](https://github.com/apache/plc4x/assets/651105/48a2b64c-4148-4e16-940e-bbfdc812307f)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1741242982

   Please give the current 0.11.0-SNAPSHOT version a try and check if the problem is gone.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1741241339

   ![image](https://github.com/apache/plc4x/assets/651105/97ce78d9-a4d1-4574-8d6d-2e5fe0c88d67)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "qtvbwfn (via GitHub)" <gi...@apache.org>.
qtvbwfn commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1848326095

   ![image](https://github.com/apache/plc4x/assets/5848026/eebaf06d-2207-4b9d-b6f9-513039c39d56)
   ![image](https://github.com/apache/plc4x/assets/5848026/acbf62c9-e85f-4e49-8e47-cf3d3cb192e2)
   [SecureChannel.java.txt](https://github.com/apache/plc4x/files/13623416/SecureChannel.java.txt)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "christofe-lintermans-actemium (via GitHub)" <gi...@apache.org>.
christofe-lintermans-actemium commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2050417286

   Hi everyone,
   
   I have updated PLC4X to version 0.12 which contains the commits for #1007. Unfortunately, the memory leak issue persists.
   
   ![image](https://github.com/apache/plc4x/assets/65465652/cfa10482-f3d1-4f79-a6e8-1c85ee46e86e)
   
   Does anyone have insights into the root cause of this problem? I am willing to investigate further.
   
   I aim to use PLC4X exclusively as the source/sink library for all my data projects. For S7 and Modbus protocols, the performance and stability are satisfactory, if not for occasional connection interruptions but are handled by NiFi's timeout settings. However, the Out of Memory (OOM) issue with OPC UA is particularly problematic.
   
   Kind regards,
   
   Christofe


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "christofe-lintermans-actemium (via GitHub)" <gi...@apache.org>.
christofe-lintermans-actemium commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2051371277

   > @christofe-lintermans-actemium It used to in 0.8 release. Since 0.10 there is in-house implementation of PLC4X driver which rely on same infrastructure as S7 and Modbus drivers.
   
   I didn't look the code in depth yet :)
   
   Is it ok that the unused dependencies are removed to avoid confusion in the future?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "splatch (via GitHub)" <gi...@apache.org>.
splatch commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2050446709

   > However, the Out of Memory (OOM) issue with OPC UA is particularly problematic.
   
   I have hoped that changes we did before 0.11 would help, but they didn't. Looking at the graph and also brief verification you did with S7 and Modbus it is clear that we have a memory (or other resource) leak within opc ua protocol logic itself.
   One bug which I know is present is connection hanging when authentication token expires, the refresh of token makes results in no further traffic on the connection. It could be that we keep generating packets, but OPC server do not answer them leading to growth of heap and crash. The default lifetime I saw with some PLCs is somewhere between 1h15m-1h30m (75-90 minutes) which seem to match, but not exactly, graph you have. The first period in your last snapshot, from 13:30 to 14:00 seem stable, leak gets visible from 14:15. Second period is stable just from 16:15 to 16:30. It gets into troubles instantly after that, as the available reclaimed memory is smaller and smaller. 
   
   I did collect some memory dumps with OPC UA simulator, however it did not reveal anything suspicious with few tags.
   @christofe-lintermans-actemium can you share how many tags you poll and how subscriptions are divided? I will try to build a reproducer too.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "splatch (via GitHub)" <gi...@apache.org>.
splatch commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2051639334

   I need to tweak tests, cause they caught this change (which is good!) and got stuck while checking lifecycle. Beyond that it works.
   
   You can checkout `issue/1101` branch and build & deploy nifi adapter. If nifi has its own component, just swap its version to 0.13-SNAPSHOT after you built a branch to pull artifacts through your local repo.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "takraj (via GitHub)" <gi...@apache.org>.
takraj commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1755594061

   @chrisdutz I have tried the revision tagged with [v0.11.0](https://github.com/apache/plc4x/releases/tag/v0.11.0), but the problem does not seem to be resolved yet. :(
   
   ```
   ~/plc4x$ git log -1
   commit d22042ef079ae93120770a95704571118d9c871e (HEAD, tag: v0.11.0)
   Author: Christofer Dutz <cd...@apache.org>
   Date:   Mon Oct 2 09:51:59 2023 +0200
   
       [maven-release-plugin] prepare release v0.11.0
   ```
   
   As you can see on the screenshot below, the heap usage is still constantly increasing:
   ![image](https://github.com/apache/plc4x/assets/2440418/b3608f84-e262-47b6-b022-e8cbfc7f2550)
   
   Tested with the following code:
   ```java
   public class MemoryLeakDemo {
   
       public static void main(String[] args) throws Exception {
           PlcDriverManager driverManager = new DefaultPlcDriverManager();
           PlcConnectionManager connectionManager = driverManager.getConnectionManager();
   
           AtomicBoolean running = new AtomicBoolean(true);
           Runtime.getRuntime().addShutdownHook(new Thread(() -> running.set(true)));
   
           while (running.get()) {
               PlcConnection connection = connectionManager.getConnection("opcua:tcp://127.0.0.1:12686/milo?discovery=false");
               try {
                   Thread.sleep(100);
               } finally {
                   connection.close();
               }
           }
       }
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1741187655

   Ok ... just noticed I was running it in the IntelliJ profiler, not JProfiler ... I split up the application into a server (that just starts milo) and a client (with your code) ... when profilling only the client I can see a constant increase in sleeping threads ... I should probably figgure out why this is happening and fix it before the 0.11.0 release ...
   ![image](https://github.com/apache/plc4x/assets/651105/a90f860e-6bf3-43b3-8172-5e85992fa436)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "qtvbwfn (via GitHub)" <gi...@apache.org>.
qtvbwfn commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1848312047

   > ### What happened?
   > The OPC-UA driver seem to leak memory when closing a connection object. This issue sooner or later lead to application crash with OOM error. Workaround would be to reuse connection objects, but then we face the issue #1100, which I believe renders a fix for this pretty urgent.
   > 
   > ![Screenshot from 2023-09-23 14-14-10](https://private-user-images.githubusercontent.com/2440418/270109529-17d5329b-e1ed-459c-bd1f-5d3339b22982.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDIxMDg2ODcsIm5iZiI6MTcwMjEwODM4NywicGF0aCI6Ii8yNDQwNDE4LzI3MDEwOTUyOS0xN2Q1MzI5Yi1lMWVkLTQ1OWMtYmQxZi01ZDMzMzliMjI5ODIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQUlXTkpZQVg0Q1NWRUg1M0ElMkYyMDIzMTIwOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyMzEyMDlUMDc1MzA3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YWJhNzhlZjEzM2NlMzMxZjQyZTc2MWY5YzQxNGNjMzU4YzliMjIyNjdiMWZjMTllMmQ1MTZiMzM1MDRhZDRlYSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.Or8mol9RudsyWBXoXcLdNGRsuCZqq7ephJ90EK2hadE)
   > 
   > Example code to reproduce the issue:
   > 
   > ```
   > PlcDriverManager driverManager = new PlcDriverManager();
   > 
   > AtomicBoolean running = new AtomicBoolean(true);
   > Runtime.getRuntime().addShutdownHook(new Thread(() -> running.set(true)));
   > 
   > while (running.get()) {
   >     PlcConnection connection = driverManager.getConnection("opcua:tcp://127.0.0.1:40185/milo?discovery=false");
   >     try {
   >         Thread.sleep(100);
   >     } finally {
   >         connection.close();
   >     }
   > }
   > ```
   > 
   > ## Some additional charts
   > ![Screenshot from 2023-09-23 14-23-14](https://private-user-images.githubusercontent.com/2440418/270109655-1384d3d8-63b8-4abb-ac75-4843d9bf72b2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDIxMDg2ODcsIm5iZiI6MTcwMjEwODM4NywicGF0aCI6Ii8yNDQwNDE4LzI3MDEwOTY1NS0xMzg0ZDNkOC02M2I4LTRhYmItYWM3NS00ODQzZDliZjcyYjIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQUlXTkpZQVg0Q1NWRUg1M0ElMkYyMDIzMTIwOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyMzEyMDlUMDc1MzA3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjJkOTMwOTllZTgzYmZhNTA5Mzc2ZDM4MzkwODVkNjk1YjczZjNhNDJlN2QyNDY1ZDhkOTlkNTdlNTgzMjMxOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.pnRLv3al4dwtHBIkkc1d7GZhPNJfg0VCbzhDZybdlAI)
   > 
   > ![Screenshot from 2023-09-23 14-08-05](https://private-user-images.githubusercontent.com/2440418/270109667-0a50afb6-3d8d-436f-afcb-a3bb7253f1f1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDIxMDg2ODcsIm5iZiI6MTcwMjEwODM4NywicGF0aCI6Ii8yNDQwNDE4LzI3MDEwOTY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logs
   > [logs-before-oom.txt](https://github.com/apache/plc4x/files/12706498/logs-before-oom.txt)
   > 
   > ## Heap dumps
   > * [MemoryLeakDemo_1045304_23_09_2023_12_41_27.zip](https://github.com/apache/plc4x/files/12706514/MemoryLeakDemo_1045304_23_09_2023_12_41_27.zip)
   > * [MemoryLeakDemo_1045304_23_09_2023_13_02_21.zip](https://github.com/apache/plc4x/files/12706515/MemoryLeakDemo_1045304_23_09_2023_13_02_21.zip)
   > * [MemoryLeakDemo_1045304_23_09_2023_14_05_15.zip](https://github.com/apache/plc4x/files/12706519/MemoryLeakDemo_1045304_23_09_2023_14_05_15.zip)
   > 
   > ### Version
   > v0.10.0
   > 
   > ### Programming Languages
   > * [x]  plc4j
   > * [ ]  plc4go
   > * [ ]  plc4c
   > * [ ]  plc4net
   > 
   > ### Protocols
   > * [ ]  AB-Ethernet
   > * [ ]  ADS /AMS
   > * [ ]  BACnet/IP
   > * [ ]  CANopen
   > * [ ]  DeltaV
   > * [ ]  DF1
   > * [ ]  EtherNet/IP
   > * [ ]  Firmata
   > * [ ]  KNXnet/IP
   > * [ ]  Modbus
   > * [x]  OPC-UA
   > * [ ]  S7
   hi:
       It took me about three days, and I have fixed the thread and memory overflow issues in the V0.11.0 version. Can you create a new branch 0.11.1-SNAPSHOT for me to submit my code?
    The main issue is that the keepAlive in SecureChannel causes the channel to be occupied for a long time without being released.
   @chrisdutz @takraj @hutcheb 
   ![image](https://github.com/apache/plc4x/assets/5848026/4c6cda1e-4834-43c9-99b5-456f61cd543a)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1873807752

   I would strongly assume it's the same issue, as from my knowledge interenally all integration modules use the same components. So this issue should probably be observalble in all integration modules.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "splatch (via GitHub)" <gi...@apache.org>.
splatch commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1873981065

   @christofe-lintermans-actemium I believe that #1007 might address some of these issues as it cleans up some of driver internals which could loose consistency over last two releases (0.10-0.11) and fall behind with stability. I am awaiting for feedback on field testing with real devices which should be completed this or next week after which I would like to merge these changes to develop. Then the Apache Nifi team will be able to produce new development build which should be free of (major) memory leaks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1873992005

   Aaaah ... cool ... well in that case ... I guess as soon as these changes make it back to develop, sounds like a good time for releasing ;-) (I guess we've got enough stuff in there already)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1741191662

   ![image](https://github.com/apache/plc4x/assets/651105/204723f9-8db2-4c74-8fa1-1f6668c4cec5)
    Should have been this image


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1741001121

   Having seen now that you were using the pre 0.10.0 syntax for creating the connection, I think you have stumbled over a problem that we have already addresses in 0.10.0-SNAPSHOT ... we're planning on releasing that in the next few days. Would be cool, if you could have a look if this is fixed for your case too. 
   
   I am currently running an updated version of your program in JProfiler and am not seeing any increase in memory usage.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1741004332

   ![image](https://github.com/apache/plc4x/assets/651105/fd8f2dfd-ddbd-4d42-a421-63aca367fbe1)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
chrisdutz commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1848321570

   I the world of plcs generally connections should be reused, as for most connections establishing a connection is pretty cost intensive. I know that opc-ua needs to resolve some things when connecting. 
   
   So I agree, that both issues should be addressed.
   
   Just not sure when. If nobody else takes on the issue, generally opc-ua related issues are pretty low on my personal priority list 😉


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "splatch (via GitHub)" <gi...@apache.org>.
splatch commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2051358991

   > PLC4X uses eclipse milo underlying for the OPCUA driver.
   
   @christofe-lintermans-actemium It used to in 0.8 release. Since 0.10 there is in-house implementation of PLC4X driver which rely on same infrastructure as S7 and Modbus drivers. 
   
   @qtvbwfn thank you for the hint, I'll check what's going on there!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "splatch (via GitHub)" <gi...@apache.org>.
splatch commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2051373537

   I see where the gap between s7 and opcua is, working on test right now.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "splatch (via GitHub)" <gi...@apache.org>.
splatch commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2051536114

   Please have a look on PR I just created, it makes sure that discovery connection, transaction manager and a lot of threads gets shut.
   
   Chris fixes from few months ago worked fine, however while working on UA security I fixed discovery connection which made its resources hang again. With above fix thread count stays flat, even if new connection is created every second:
   
   ![image](https://github.com/apache/plc4x/assets/199488/ea98a0f1-5ba8-4311-83f4-5e90326f78c9)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "qtvbwfn (via GitHub)" <gi...@apache.org>.
qtvbwfn commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-1846882645

   I think I have already handled the issue of thread pool leakage, but I'm not sure how to release the related resources.
   
   V0.11.0
   
   please help me  @chrisdutz @takraj 
   
   ![image](https://github.com/apache/plc4x/assets/5848026/ccd323bd-6ce6-4209-b98a-c042f3e0b073)
   ![image](https://github.com/apache/plc4x/assets/5848026/9fca9fde-addf-4637-be5a-f05ff88c1e70)
   
   dump file:
   
   [plc4x.zip](https://github.com/apache/plc4x/files/13612561/plc4x.zip)
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: plc4j-driver-opcua seems to leak memory

Posted by "christofe-lintermans-actemium (via GitHub)" <gi...@apache.org>.
christofe-lintermans-actemium commented on issue #1101:
URL: https://github.com/apache/plc4x/issues/1101#issuecomment-2065827833

   Hi all,
   
   I have checked out the specific branch:
   
   ![image](https://github.com/apache/plc4x/assets/65465652/2365af9a-7e67-4735-8103-ebdccb8650bf)
   
   I have built the nifi integrations and deployed it:
   
   ![image](https://github.com/apache/plc4x/assets/65465652/146862e4-4a4b-46ac-883d-b6aad6b0935a)
   
   I didn't had any OOM problems anymore
   
   ![image](https://github.com/apache/plc4x/assets/65465652/5a0ddffa-333b-4620-80d5-d48c0df4a557)
   
   (red line is time when I replaced the plc4x nar)
   
   Thank you very much for your support, much appreciated!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org