This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Limit of Memory size 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 "Limit of Memory size" Watch "Limit of Memory size" New topic
Author

Limit of Memory size

Nitin Shivaram
Ranch Hand

Joined: Jan 17, 2001
Posts: 71
Hi,
Does anyone know if there is a limit on the memory(Heap) size with java?
tia


Nitin S<br />Sun Certified Java Programmer for the Java 2 platform.<br />Tekmetrics Certified Java Programmer For the Java 2 Platform.
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

You can define the Maximum and Initial Heap Size for the JVM
java -Xmx256M -Xms64M com.me.RunThisClass


- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Nitin Shivaram
Ranch Hand

Joined: Jan 17, 2001
Posts: 71
i know you could use those switches to set the heap size, but is there a upper limit on the heap
size.
Does JDK in any way impose the upper limit heap size restriction?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
The JDK imposes whatever limit is set using these switches - if no limit is set, the default maximum heap size is 64 MB. As far as the JDK is concerned, there is no maximum to the amount you can set here. However, if you use more than is available on your operating system, the OS (not the JVM) may limit the size that the JVM can allocate. Or your system my just run incredibly slowly as it is forced to use increasing amounts of virtual memory. All this is system-dependent however - outside the JDK's control.


"I'm not back." - Bill Harding, Twister
Nitin Shivaram
Ranch Hand

Joined: Jan 17, 2001
Posts: 71
Sounds logical, But say i have 4 GB of primary available primary memory, and if i start the JVM with a starting size of 3 GB and upto 4GB, will that affect the performance?
To summarize my question, does the size of the heap affect the performance?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
If you've really got that much memory available, then no, it won't affect performance for you to allocate a huge heap. I have a hard time imagining systems and applications where this is both practical and necessary, but if you've got a huge system and nothing better to do with it, go for it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Limit of Memory size
 
Similar Threads
howto build a queue from 2 stacks
Is there a limit on the number of sql statements in a single transaction?
maximum size in memory file
Is there any memory size limit for each and every workspace in eclipse?
Build a file in Memory