@Override
    public Optional<JvmMemoryPercentage> getMemoryPercentage() {
        if (memoryPercentage != null) return Optional.of(JvmMemoryPercentage.of(memoryPercentage));

        if (isHostedVespa()) {
            int heapSizePercentageOfAvailable = heapSizePercentageOfAvailable();
            if (getContainers().isEmpty()) return Optional.of(JvmMemoryPercentage.of(heapSizePercentageOfAvailable)); // Node memory is not known

            // Node memory is known, so compute heap size as a percentage of available memory (excluding overhead, which the startup scripts also account for)
            double totalMemoryGb = getContainers().stream().mapToDouble(c -> c.getHostResource().realResources().memoryGiB()).min().orElseThrow();
            double totalMemoryMinusOverhead = Math.max(0, totalMemoryGb - Host.memoryOverheadGb);
            double onnxModelCostGb = onnxModelCostCalculator.aggregatedModelCostInBytes() / (1024D * 1024 * 1024);
            double availableMemoryGb = Math.max(0, totalMemoryMinusOverhead - onnxModelCostGb);
            int memoryPercentageOfAvailable = (int) (heapSizePercentageOfAvailable * availableMemoryGb / totalMemoryMinusOverhead);
            int memoryPercentageOfTotal = (int) (heapSizePercentageOfAvailable * availableMemoryGb / totalMemoryGb);
            logger.log(FINE, () -> ("%s: memoryPercentageOfAvailable=%d, memoryPercentageOfTotal=%d, " +
                                    "availableMemoryGb=%f, totalMemoryGb=%f, heapSizePercentageOfAvailable=%d, onnxModelCostGb=%f")
                    .formatted(id(), memoryPercentageOfAvailable, memoryPercentageOfTotal,
                               availableMemoryGb, totalMemoryGb, heapSizePercentageOfAvailable, onnxModelCostGb));
            return Optional.of(JvmMemoryPercentage.of(memoryPercentageOfAvailable, memoryPercentageOfTotal,
                                                      availableMemoryGb * heapSizePercentageOfAvailable * 1e-2));
        }
        return Optional.empty();
    }
The heap size % of total memory available to the JVM process.
config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java