-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vm/io] Avoid leaking Handle::data_ready_ on Windows.
Handle::data_ready_ contains bytes which are ready to be sent to Dart side. Not all code paths fully drain this buffer and delete it before destroying the handle, for example directory watch implementation was prone to leaking data_ready_ when subscription was cancelled. This CL switches the code to use unique_ptr to hold on to data_ready_ which makes sure that it is deleted when Handle is destroyed. The code would benefit from holding all OverlappedBuffer instances through unique_ptr but that is a much larger refactoring which we leave for a later date. Fixes #52715 TEST=standalone{,_2}/regress_52715_test Bug: 52715 Cq-Include-Trybots: luci.dart.try:vm-win-release-x64-try,vm-win-debug-x64-try,vm-aot-win-release-x64-try,analyzer-win-release-try Change-Id: Ie8d728b823de7e8f9de1489898e270580c2af269 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311841 Commit-Queue: Slava Egorov <[email protected]> Commit-Queue: Martin Kustermann <[email protected]> Reviewed-by: Martin Kustermann <[email protected]> Auto-Submit: Slava Egorov <[email protected]>
- Loading branch information
Showing
4 changed files
with
57 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// 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. | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:expect/expect.dart'; | ||
|
||
void main() async { | ||
final startRss = ProcessInfo.currentRss; | ||
|
||
for (var i = 0; i < 1024; i++) { | ||
final subscription = Directory.systemTemp.watch().listen((event) {}); | ||
await subscription.cancel(); | ||
} | ||
|
||
final endRss = ProcessInfo.currentRss; | ||
final allocatedBytes = (endRss - startRss); | ||
final limit = 10 * 1024 * 1024; | ||
Expect.isTrue(allocatedBytes < limit, | ||
'expected VM RSS growth to be below ${limit} but got ${allocatedBytes}'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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; | ||
|
||
for (var i = 0; i < 1024; i++) { | ||
final subscription = Directory.systemTemp.watch().listen((event) {}); | ||
await subscription.cancel(); | ||
} | ||
|
||
final endRss = ProcessInfo.currentRss; | ||
final allocatedBytes = (endRss - startRss); | ||
final limit = 10 * 1024 * 1024; | ||
Expect.isTrue(allocatedBytes < limit, | ||
'expected VM RSS growth to be below ${limit} but got ${allocatedBytes}'); | ||
} |