mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
c8dea19836
This reserved space can only be allocated from after an allocation has failed from OutOfMemory, and once some portion of this space is used, refilling it is the first allocation performed after GC. Also avoid greatly slowing down from ineffective scavenges as the memory limit is reached. Bug: https://github.com/dart-lang/sdk/issues/43543 Bug: https://github.com/dart-lang/sdk/issues/43642 Bug: b/169880355 Change-Id: Ic7132cb34d7a7d13c67661f057f00dd74306251c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165862 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
55 lines
1.3 KiB
Dart
55 lines
1.3 KiB
Dart
// Copyright (c) 2020, 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.
|
|
|
|
// VMOptions=--old_gen_heap_size=20
|
|
|
|
import "dart:io";
|
|
import "dart:isolate";
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
handleRequest(request) {
|
|
if (request % 2 == 0) {
|
|
var leak = [];
|
|
while (true) {
|
|
leak = [leak];
|
|
}
|
|
}
|
|
return "Okay";
|
|
}
|
|
|
|
handleMessage(message) {
|
|
print(">> $message");
|
|
var responsePort = message[0];
|
|
var request = message[1];
|
|
try {
|
|
responsePort.send(<dynamic>[request, handleRequest(request)]);
|
|
} catch (e, st) {
|
|
responsePort.send(<dynamic>[request, "Failed: $e\n$st"]);
|
|
}
|
|
}
|
|
|
|
main(args) async {
|
|
var child = new RawReceivePort(handleMessage);
|
|
|
|
var parent;
|
|
parent = new RawReceivePort((message) {
|
|
print("<< $message");
|
|
var request = message[0];
|
|
var response = message[1];
|
|
if (request % 2 == 0) {
|
|
Expect.isTrue(response.contains("Out of Memory"));
|
|
} else {
|
|
Expect.equals("Okay", response);
|
|
}
|
|
if (request == 5) {
|
|
child.close();
|
|
parent.close();
|
|
} else {
|
|
child.sendPort.send(<dynamic>[parent.sendPort, request + 1]);
|
|
}
|
|
});
|
|
|
|
child.sendPort.send(<dynamic>[parent.sendPort, 1]);
|
|
}
|