Limiting java application's memory and cpu usage

后端 未结 8 677
南笙
南笙 2020-12-18 21:45

Say, \"run myApp.jar with cpu=800 and memory=1024\"

Ive been doing java programming for many years and it is an embarrasment to ask this question. I don\'t even know

8条回答
  •  遥遥无期
    2020-12-18 22:20

    For CPU you can try my new lib :).

    https://github.com/dyorgio/cpu-watcher

    Example of use:

    // Limit process by PID to 25% of host cpu usage
    CpuWatcher cpuWatcher = new CpuWatcher(pid, 25f);
    cpuWatcher.start();
    

提交回复
热议问题