plc4x: [Bug]: plc4j-driver-opcua seems to leak memory
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.
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
Logs
Heap dumps
- MemoryLeakDemo_1045304_23_09_2023_12_41_27.zip
- MemoryLeakDemo_1045304_23_09_2023_13_02_21.zip
- MemoryLeakDemo_1045304_23_09_2023_14_05_15.zip
Version
v0.10.0
Programming Languages
- plc4j
- plc4go
- plc4c
- plc4net
Protocols
- AB-Ethernet
- ADS /AMS
- BACnet/IP
- CANopen
- DeltaV
- DF1
- EtherNet/IP
- Firmata
- KNXnet/IP
- Modbus
- OPC-UA
- S7
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 33 (26 by maintainers)
Commits related to this issue
- Cleanup discovery connection resources. Closes #1101. Signed-off-by: Łukasz Dywicki <luke@code-house.org> — committed to apache/plc4x by splatch 3 years ago
- Cleanup discovery connection resources. Update of unit test to verify method exits. Closes #1101. Signed-off-by: Łukasz Dywicki <luke@code-house.org> — committed to apache/plc4x by splatch 3 years ago
- fix(plc4j/opcua): Cleanup discovery connection resources. Update of unit test to verify method exits. Closes #1101. Signed-off-by: Łukasz Dywicki <luke@code-house.org> — committed to apache/plc4x by splatch 3 years ago
- fix(plc4j/opcua): Cleanup discovery connection resources. Update of unit test to verify method exits. Closes #1101. Signed-off-by: Łukasz Dywicki <luke@code-house.org> — committed to apache/plc4x by splatch 3 years ago
- Refactor / improve python modbus (#1581) * fix(plc4py/umas): Start to add write support * build(deps): bump github.com/stretchr/testify in /plc4go (#1439) Bumps [github.com/stretchr/testify](ht... — committed to apache/plc4x by ottlukas 3 years ago
- Refactor / improve python modbus (#1581) * fix(plc4py/umas): Start to add write support * build(deps): bump github.com/stretchr/testify in /plc4go (#1439) Bumps [github.com/stretchr/testify](https:... — committed to apache/plc4x by ottlukas 3 years ago
- fix(plc4py/umas): Write Support (#1463) * fix(plc4py/umas): Start to add write support * build(deps): bump github.com/stretchr/testify in /plc4go (#1439) Bumps [github.com/stretchr/testify](htt... — committed to apache/plc4x by hutcheb 2 years ago
Hi all,
I have checked out the specific branch:
I have built the nifi integrations and deployed it:
I didn’t had any OOM problems anymore
(red line is time when I replaced the plc4x nar)
Thank you very much for your support, much appreciated!
@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.
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.