Skip to content

Commit

Permalink
8301326: Optimize compiler/uncommontrap/TestDeoptOOM.java test
Browse files Browse the repository at this point in the history
Reviewed-by: rcastanedalo, thartmann
  • Loading branch information
xmas92 committed Jan 31, 2023
1 parent 9cc0171 commit cdb4ba9
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -67,19 +67,24 @@ static class LinkedList {

static LinkedList ll;

static void consume_all_memory() {
int size = 128 * 1024 * 1024;
while(size > 0) {
try {
while(true) {
ll = new LinkedList(ll, size);
}
} catch(OutOfMemoryError oom) {
static void alloc_in_chunks(int size) {
try {
while(true) {
ll = new LinkedList(ll, size);
}
size = size / 2;
} catch(OutOfMemoryError oom) {
}
}

static void consume_all_memory() {
// O(MiB) allocations
alloc_in_chunks(1024*1024);
// O(KiB) allocations
alloc_in_chunks(1024);
// O(B) allocations
alloc_in_chunks(1);
}

static void free_memory() {
ll = null;
}
Expand Down

1 comment on commit cdb4ba9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.