From cdb4ba9657ceae426281ead96aa4a125c7b97e6f Mon Sep 17 00:00:00 2001 From: Axel Boldt-Christmas Date: Tue, 31 Jan 2023 07:54:20 +0000 Subject: [PATCH] 8301326: Optimize compiler/uncommontrap/TestDeoptOOM.java test Reviewed-by: rcastanedalo, thartmann --- .../compiler/uncommontrap/TestDeoptOOM.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java b/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java index 8692fc924ae..2f9a456996f 100644 --- a/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java +++ b/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 @@ -67,19 +67,24 @@ public class TestDeoptOOM { 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; }