io.opentelemetry.instrumentation.test.utils.GcUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opentelemetry-testing-common Show documentation
Show all versions of opentelemetry-testing-common Show documentation
OpenTelemetry Javaagent testing commons
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.instrumentation.test.utils;
import java.lang.ref.WeakReference;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.TimeoutException;
public final class GcUtils {
private static final StringBuilder garbage = new StringBuilder();
public static void awaitGc(Duration timeout) throws InterruptedException, TimeoutException {
Object obj = new Object();
WeakReference