You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by "chrisdutz (via GitHub)" <gi...@apache.org> on 2024/02/06 10:25:33 UTC

Re: [I] modbus connection causes memory leak

chrisdutz commented on issue #636:
URL: https://github.com/apache/plc4x/issues/636#issuecomment-1929208469

   It seems this is still an issue. I created this little program:
   `
   package org.apache.plc4x.java.modbus;
   
   import org.apache.plc4x.java.api.PlcConnection;
   import org.apache.plc4x.java.api.PlcDriverManager;
   import org.apache.plc4x.java.api.messages.PlcWriteRequest;
   import org.apache.plc4x.java.api.messages.PlcWriteResponse;
   import org.apache.plc4x.java.api.types.PlcResponseCode;
   import org.apache.plc4x.java.spi.values.PlcDINT;
   import org.apache.plc4x.java.spi.values.PlcREAL;
   
   public class ManualTest {
   
       public static void main(String[] args) throws Exception {
           while (true) {
               String connectionString = "modbus-tcp://192.168.23.30";
               try (PlcConnection plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection(connectionString)) {
                   PlcWriteRequest.Builder builder = plcConnection.writeRequestBuilder();
                   builder.addTagAddress("value-1","holding-register:14:DINT",new PlcDINT(-242442424));
                   builder.addTagAddress("value-2","holding-register:26:REAL",new PlcREAL(3.141593F));
                   PlcWriteRequest writeRequest = builder.build();
                   PlcWriteResponse response = writeRequest.execute().get();
                   for (String fieldName :
                       response.getTagNames()) {
                       if(response.getResponseCode(fieldName) == PlcResponseCode.OK) {
                           System.out.println("Value[" + fieldName + "]: updated");
                       } else {
                           System.out.println("Error[" + fieldName + "]: " + response.getResponseCode(fieldName).name());
                       }
                   }
                   System.out.println("done");
               }
           }
       }
   }
   `
   And I can see a constantly increasing number of open threads.
   ![Bildschirmfoto 2024-02-06 um 11 24 06](https://github.com/apache/plc4x/assets/651105/9fc1c0f3-ac21-49da-8b5f-f2ce80cecac1)
   


-- 
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