my dog learned polymorphism*
The moose likes Java in General and the fly likes JVM memory allocation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "JVM memory allocation" Watch "JVM memory allocation" New topic
Author

JVM memory allocation

Blikkies Marais
Ranch Hand

Joined: Jun 12, 2003
Posts: 50
How do I set the JVM memory allocation for a class that has not main method? I have an application, where a class is invoked from a startup servlet. How do I set the memory allocation for this application?
Eg. java -mx 20m myClass
is for a specific class. How do I set it for an application?
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
The min/max heap size is not set for any specific class or even a specific application, -- it's the heap size for JVM itself.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8834
    
    7

Like I was saying in this thread, the VM memory settings is for the entire VM, not for an individual class.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Blikkies Marais
Ranch Hand

Joined: Jun 12, 2003
Posts: 50
How do I do this, what is the syntax?
If I try "java -mx1024m", I get prompted with the "java -help" options. How do I know if the VM memory has been set?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8834
    
    7

As I said in the previous thread, you need to pass the "java" command the name of a class, otherwise it doesn't do anything. I get the impression you are trying to "set" some property on the "java" command in order to solve your OutOfMemoryException
It doesn't work that way. The "java" command takes arguments only for the current run. Even if you started two VM's with different arguments, the arguments of the one would not effect the other.
And as for syntax, you have it correct in the first message of this thread.
[ October 28, 2003: Message edited by: Joe Ess ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JVM memory allocation
 
Similar Threads
Garbage collection
About Memory allocation by new()
java.lang.OutOfMemoryError
JVM memeory allocation
Garbage Collection and Virtual Memory