限制java应用程序的内存和CPU使用率 [英] Limiting java application's memory and cpu usage

查看:817
本文介绍了限制java应用程序的内存和CPU使用率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说,运行myApp.jar,cpu = 800,内存= 1024

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

多年来我一直在做java编程,这是一个令人尴尬的问题。题。我甚至不知道这是否可能。如果是这样,怎么样?

Ive been doing java programming for many years and it is an embarrasment to ask this question. I don't even know whether this is possible or not. And if so, how?

我只想知道是否可以设置java程序的最大内存和CPU使用率。我突然想到了这一点,因为我最近开始开发移动应用程序。我想知道应用程序在具有非常有限的内存和处理器的设备上的行为。

What I just want know is if it is possible to set a java program's maximum memory and cpu usage. I suddenly thought of this because of I recently started developing mobile apps. I want to know how the app will behave on the device which has very limited memory and processor.

我看到物理引擎带有在浏览器上运行的演示应用程序,或者我可以在我的PC上执行。如果我在移动设备上运行它会怎么样?性能是否相同?我不是开发一个示例移动应用程序来测试库的性能,而是首先使用我的PC使用特定的cpu和内存来运行它。

I saw physics engines with demo apps that run on the browser or I can execute on my PC. What if I run them on a mobile device? Will the performance be the same? Rather than developing a sample mobile app to test the library's performance, I'd rather run it with a specific cpu and memory using my PC first.

我试过谷歌搜索方式...我发现的只是监控和性能调整。我可能使用了错误的关键字。

I tried googling by the way... all i found was monitoring and performance tuning. I may be using wrong keywords.

推荐答案

您可以通过-Xmx选项限制内存使用量,您可以通过设置优先级来限制CPU使用率进程和/或CPU亲和力。

you can limit memory usage by -Xmx option and you can limit CPU usage by setting priority of the process and/or CPU affinity.

这篇关于限制java应用程序的内存和CPU使用率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆