Why are my Runtime Memory Logs Much Lower on OpenShift than on Localhost?

35 Views Asked by At

The problem is: while running on localhost, memory logged programmatically in runtime is 1Gb Total/ 500Mb free. When running on Openshift this values are approximately 10 times less: 110Mb Total, 40 Mb free. Can anyone explain what is going on? Thanks in advance.

For logging I`m using

private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);

    public void start() {
        Runnable logger = new Runnable() {
            public void run() {
                long totalMemory = Runtime.getRuntime().totalMemory();
                long freeMemory = Runtime.getRuntime().freeMemory();
                System.out.println("Total Memory: " + totalMemory/1000000 + " MB Free Memory: " + freeMemory/1000000 + " MB");
            }
        };
        scheduler.scheduleAtFixedRate(logger, 0, 5, TimeUnit.SECONDS);

JVM version on OpenShift: openjdk version "11.0.19" 2023-04-18 LTS OpenJDK Runtime Environment (Red_Hat-11.0.19.0.7-2) (build 11.0.19+7-LTS) OpenJDK 64-Bit Server VM (Red_Hat-11.0.19.0.7-2) (build 11.0.19+7-LTS, mixed mode, sharing)

JVM version on localhost: openjdk version "11.0.18" 2023-01-17 OpenJDK Runtime Environment OpenLogic-OpenJDK (build 11.0.18+10-adhoc..jdk11u) OpenJDK 64-Bit Server VM OpenLogic-OpenJDK (build 11.0.18+10-adhoc..jdk11u, mixed mode)

0

There are 0 best solutions below