mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:49:47 +00:00
8f21c8ed2a
Bug: https://github.com/dart-lang/sdk/issues/52816 Change-Id: I4e50180a9285727cc2e275dd17dd6855f21a0b6e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311926 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Alexander Aprelev <aam@google.com>
27 lines
952 B
Dart
27 lines
952 B
Dart
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// Verify that cancelled [Directory.watch] subscriptions do not waste memory.
|
|
|
|
// @dart=2.9
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
void main() async {
|
|
final startRss = ProcessInfo.currentRss; //# measure: ok
|
|
|
|
for (var i = 0; i < 1024; i++) {
|
|
final subscription = Directory.systemTemp.watch().listen((event) {});
|
|
await subscription.cancel();
|
|
}
|
|
|
|
final endRss = ProcessInfo.currentRss; //# measure: continued
|
|
final allocatedBytes = (endRss - startRss); //# measure: continued
|
|
final limit = 10 * 1024 * 1024; //# measure: continued
|
|
Expect.isTrue(allocatedBytes < limit, //# measure: continued
|
|
'expected VM RSS growth to be below ${limit} but got ${allocatedBytes}'); //# measure: continued
|
|
}
|