Interface ProcessSampler

All Known Implementing Classes:
ProcessSampler.Proc, ProcessSampler.PsLsof

public interface ProcessSampler
What a process is holding, read from outside it.

From outside because none of the five libraries reports any of this, and teaching all five would measure what each believes about itself rather than what the operating system can see it holding. A pid is a pid in every language, so a sixth client costs nothing here.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    Linux: /proc/<pid>/status for VmRSS and Threads, and the entries of /proc/<pid>/fd for descriptors.
    static final class 
    macOS and other Unixes: ps -o rss=, lsof -p and ps -M, counted exactly as scripts/soak.sh counted them so a report from either compares with the other: every line lsof prints, header included, and every thread line ps prints after its header.
    static final record 
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    sample(long pid)
     
  • Method Details

    • sample

      Optional<ProcessSampler.Usage> sample(long pid)
      Returns:
      what the process holds, or empty if it is not running
    • forThisOs

      static ProcessSampler forThisOs()
      Returns:
      the sampler for this operating system: /proc on Linux, ps and lsof elsewhere