Java limiting resource usage

99封情书 提交于 2019-12-03 23:24:28

You can use taskset on linux. You can also lower the priority of a process, but unless the CPU(S) are busy, a process will get as much CPU as it can use.

I have a library for dedicating thread to a core, called Java Thread Affinity, but it may have a different purpose to what you have in mind. Can you clarify why you want to do this?

I don't think that there are built-in JVM options to do these kind of tweaks, however you can limit CPU usage by setting priority and/or CPU affinity of the JVM process. If you are on Linux take a look at CPULimit that is an awesome tool to do these kind of resource limitations.

https://github.com/haosdent/jcgroup jcgroup is your best choice. You could use this library to limit the CPU shares, Disk I/O speed, Network bandwidth and etc.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!