Client retains old requests
Closed this issue · 3 comments
JosefWN commented
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();
}
Currently debugging it...
shamblett commented
Ok, your findings should be interesting.
JosefWN commented
It's the broadcast streams leaking: dart-lang/sdk#26686
PR: #188
shamblett commented
Great thanks, merged, package re published at version 9.0.3