blob: 9e3bab97c197c7dc49a000cb6355a0064bad26cc [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:isolate';
import 'dart:mojo_core';
import 'dart:typed_data';
import 'package:mojo/dart/testing/expect.dart';
RawMojoHandle leakMojoHandle() {
var pipe = new MojoMessagePipe();
Expect.isNotNull(pipe);
var endpoint = pipe.endpoints[0];
Expect.isTrue(endpoint.handle.isValid);
var handle = new MojoHandle(endpoint.handle);
// After making a high-level MojoHandle, the underlying mojo handle will have
// the native MojoClose called on it when the MojoHandle is GC'd or the VM
// shuts down.
return endpoint.handle;
}
// vmoptions: --new-gen-semi-max-size=1 --old_gen_growth_rate=1
List<int> triggerGC() {
var l = new List.filled(1000000, 7);
return l;
}
test() {
RawMojoHandle handle = leakMojoHandle();
triggerGC();
// The handle will be closed by the MojoHandle finalizer during GC, so the
// attempt to close it again will fail.
MojoResult result = handle.close();
Expect.isTrue(result.isInvalidArgument);
}
main() {
test();
}