Limiting java application's memory and cpu usage

后端 未结 8 642
南笙
南笙 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:32

    Linux:

    taskset -a -c 0,1,2,3 <program>

    Run a program and its child threads only on cores 0, 1, 2, and 3.

    0 讨论(0)
  • 2020-12-18 22:39

    The JVM has no control over CPU usage nor priority.

    JVM has control over max/min Memory usage.

    There is a workaround. It is possible to run each JVM in a separate [Docker container][1]. And control the resource (Memory, CPU, Network, IO) allocation for each container. That is exactly the added value of the Docker containers.

    [1]: The JVM has no control over CPU usage nor priority. Yet you can run each JVM in a separate Docker container. And control the resource allocation foreach container. That is exactly the added value of the Docker containers.

    0 讨论(0)
提交回复
热议问题