Class MemoryGuard

java.lang.Object
jline.solvers.ctmc.MemoryGuard

public final class MemoryGuard extends Object
Hardware-aware, profiling-calibrated memory guard for SolverCTMC. Replaces the historical hard-coded state-space size threshold with a model that (a) probes the memory actually available to this process and (b) calibrates the per-state cost of a sparse steady-state solve by profiling EJML's sparse LU once, caching the fitted power law per machine in the temp directory. Mirrors the MATLAB (ctmc_memory_gate.m / lineGetAvailableMemory.m) and Python-native (memory_guard.py) implementations, sharing the same model. Java 8 compatible: no var, no List.of, no switch expressions.
  • Field Details

    • DEFAULT_SAFETY_FRACTION

      public static final double DEFAULT_SAFETY_FRACTION
      Default fraction of available memory the solver may target.
      See Also:
  • Method Details

    • getAvailableMemoryBytes

      public static double getAvailableMemoryBytes()
      Portable memory budget probe (bytes). Because CTMC data is allocated on the JVM heap, the binding constraint is the heap headroom, further capped by free physical memory (queried via the OperatingSystemMXBean, which is implemented on all platforms). Never throws; returns a conservative constant if nothing can be determined.
    • gate

      public static MemoryGuard.GateResult gate(double logNstates, boolean force, boolean verbose, double safetyFraction)
      Hardware-aware, calibrated pre-gate.
      Parameters:
      logNstates - natural log of the worst-case state-space size
      force - bypass the hard stop (still warns)
      verbose - print the estimate
      safetyFraction - fraction of available memory allowed as budget
      Returns:
      a MemoryGuard.GateResult; ok is false only when the predicted footprint exceeds the budget and force is not set.