• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Limit of Memory size

 
Nitin Shivaram
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Does anyone know if there is a limit on the memory(Heap) size with java?
tia
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can define the Maximum and Initial Heap Size for the JVM
java -Xmx256M -Xms64M com.me.RunThisClass
 
Nitin Shivaram
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nitin Shivaram
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic