It seems that the client is retaining completed requests, causing memory and CPU utilization to grow with time. I have a long-running app in which case it becomes very apparent.
To reproduce, I created a poll_resource.dart and dart run --observe poll_resource.dart where I can see an increasing number of CoapRequest:
import 'dart:async';
import 'package:coap/coap.dart';
import 'config/coap_config.dart';
FutureOr<void> main() async {
final conf = CoapConfig();
final baseUri = Uri(scheme: 'coap', host: 'coap.me', port: conf.defaultPort);
final client = CoapClient(baseUri, config: conf);
for (var i = 1; i <= 10000; i++) {
try {
print('Sending request get /test $i to ${baseUri.host}');
final response = await client.get(Uri(path: 'test'));
print('/test response: ${response.payloadString}');
print('---');
} on Exception catch (e) {
print('CoAP encountered an exception: $e');
}
await Future<void>.delayed(const Duration(seconds: 1));
}
client.close();
}
It seems that the client is retaining completed requests, causing memory and CPU utilization to grow with time. I have a long-running app in which case it becomes very apparent.
To reproduce, I created a
poll_resource.dart
anddart run --observe poll_resource.dart
where I can see an increasing number ofCoapRequest
:Currently debugging it...