开发者

how to force operating system to give java more memory?

开发者 https://www.devze.com 2022-12-30 11:23 出处:网络
I\'ve got problem with java jar files and memory. I use netbeans 6.7 to develop an application and this application need more memory to run because it converts another files. Whenever this applicatio

I've got problem with java jar files and memory.

I use netbeans 6.7 to develop an application and this application need more memory to run because it converts another files. Whenever this application convert a 6-10 mb file, it'll crash. So I set netbeans VM Options : -Xms32m -Xmx256m and the application can convert 6-10mb files with no problem.

I Clean and Build the project so it can make a jar file of my application. I run the jar on my computer and use jconsole to monitor the memory. The maximum memory to use by the application shows 256 mb. But whenever I move it to some other computers, it shows 65-66 mb on jconsole and the application will crash when conve开发者_如何学JAVArt 6-10 mb files. So I need to use command prompt : java -jar -Xmx256m myjar.jar to execute the jar with maximum memory

Why it can be happen, in my computer the maximum memory shows 256 mb but on another computer 65-66 mb? Can I force another computer to give extra maximum memory to my application?

Thank you for your answer. I'm sorry for my inadequate English. If you all find my question is hard to understand, please let me know.

Best Regards

Denny

ps: fyi the computer i used to develop the application have 2gb ram, on the other computers i tested have 1-2 gb ram.


You answered your own question. The application must be launched with the -Xmx option.


I've found alternative, we can use : set _JAVA_OPTIONS=-Xms64m -Xmx128m in command prompt. It makes: java -Xms64m -Xmx128m become default heap memory size. I've got it here.

This way give a satisfied result for me. But if you have better way, please don't hesitate to post it. Anyway, thank you for your responses.


IIRC, the client VM used to default to 64MB heap. You have to use -Xmx or perhaps generate a launcher for your jar.


Configure the settings in 'Run Application' properties with amount of memory that you are expecting in NetBeans IDE.

0

精彩评论

暂无评论...
验证码 换一张
取 消