1

I'm trying to write PLC data into influxDB; and PLC4X EIP driver used when I use sync solution ,everything is OK; but When I try the Async solution the heap leakage will always happen my code as below:

        CompletionStage<ArrayList<Point>> cf = resp.thenApply((r) -> {
            Map<String, Object> field = new HashMap<String, Object>();
            ArrayList<Point> points = new ArrayList<>();
            for (String fieldName : r.getFieldNames()) {
                if (r.getResponseCode(fieldName) == PlcResponseCode.OK) {
                    int counter = r.getNumberOfValues(fieldName);
                    for (int i = 0; i < counter; i++) {
                        field.put(fieldName, r.getObject(fieldName, i));
                    }
                    points.add(Point.measurement(getMeasurement()).addTags(getInfluxTags(fieldName))
                            .addFields(field).time(Instant.now(),WritePrecision.MS));
                    writeapi.writePoints(points);//this is the influxdb write API Version 6.0.0
                    log.trace("AAAAAsync write to influxdb measurement={},tag={},field={}",
                            getMeasurement(),getInfluxTags(fieldName),field);
                }
            }
            return points;
        });

the issue is when writeapi be used in lambda, it looks hold the reference of the lambda , and never can release , So How can I solve it ? make the GC working fine.

xi cao
  • 11
  • 1
  • this lambda also call a log instance ,this is ok ,no leakage happen ,if only record log – xi cao Jun 28 '22 at 14:23
  • Can you add a few more information like which PLC4X Release, which Java Version you are using? - Thank you! – otluk Sep 19 '22 at 08:26

0 Answers0