All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.openlineage.client.utils.RuntimeUtils Maven / Gradle / Ivy

There is a newer version: 1.26.0
Show newest version
/*
/* Copyright 2018-2024 contributors to the OpenLineage project
/* SPDX-License-Identifier: Apache-2.0
*/
package io.openlineage.client.utils;

import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.util.List;

/**
 * Class used to access static Runtime properties. Useful for testing as it can be mocked with
 * mockStatic.
 */
public class RuntimeUtils {
  public static long freeMemory() {
    return Runtime.getRuntime().freeMemory();
  }

  public static long totalMemory() {
    return Runtime.getRuntime().totalMemory();
  }

  public static long maxMemory() {
    return Runtime.getRuntime().maxMemory();
  }

  public static double getMemoryFractionUsage() {
    return (100.0 * ((double) totalMemory())) / ((double) maxMemory());
  }

  public static List getGarbageCollectorMXBeans() {
    return ManagementFactory.getGarbageCollectorMXBeans();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy