4

I have many small java programs running in crons in my server. I have an openvz VPS, and java is very poblematic with memory and openvz.

The best solution i have come up so far is running my programs with:

java -Xmx16m class

This works ok, but I have many programs running, and i want to set the default maximum heap for all the system, so that i don't change all the start up scripts, and not have to remember to do that every time i write a new one.

I tried finding a way to set/change a global default value for my CentOS system, but i had no luck with that!

I would appreciate if someone could help me.

Thanks.

trincot
  • 317,000
  • 35
  • 244
  • 286
Nikos
  • 91
  • 1
  • 1
  • 6
  • 3
    duplicate: http://stackoverflow.com/questions/880855/increase-the-java-heap-size-permanently – Mat May 19 '11 at 19:57

2 Answers2

16

You could try adding this to your shell profile export _JAVA_OPTIONS=-Xmx16m

This may or may not work depending on what JVM you are running.

Jon
  • 5,247
  • 6
  • 30
  • 38
  • I put this in bashrc file and it worked ! Thanks! I found somewhere `export JAVA_OPTIONS=-Xmx16m` (without _) I tried it and didn't work, now I see it was written wrong. – Nikos May 19 '11 at 21:00
1

Create an environment variable _JAVA_OPTIONS and set the new value there. That should work

OscarRyz
  • 196,001
  • 113
  • 385
  • 569