We help IT Professionals succeed at work.

JVM - heap, stack Size, # of threads

rameshaa asked
Medium Priority
Last Modified: 2013-11-23

 How do I found default heap size, stack size for the
 thread, number of threads per process supported ?

 I tried with java -verbose but it didn't gave the
 info. what I expected ?

 and how the above things will vary for each OS and how
 do I found ? Is there any commands/utility available ?

 I also wanna know how many threads supported per process?

Thanx in advance,
Watch Question

I believe the default heap size starts at 2 mb, and can grow to 64 mb.  If you need more than 64mb of heap, you need to specifiy the following flags:

  -Xms<size>   for minimium heap size
  -Xmx<size>   for maximum heap size

For example:

  -Xmx256m     wil get you 256 Mb of heap

Keep in mind that you don't necessarily want to allocate a large minimum heap, because that will cause the JVM to immediately grab that much memory from the OS.

If you want to set the size of the Java thread stack, use:


The default is 512k.

As far as # of threads per process, that will depend on the OS you're running on, but most likely you will run out of memory before exhausting the number of possible threads...

Now, from a pragmatic standpoint:

1.  You shouldn't care about the default stack size, because if you're using too much stack, you've got a serious design flaw in your program.

2.  If you're creating enough threads where you have to worry about bumping into some type of maximum, you've got a serious design flaw in your program.

As far as I know, there is no command or utility that will give you this information on an OS by OS basis...

you can try some java profiling tool like jprobe or optimizeit (you can download evaluation) to get a realtime look on your heap and threads

Do you need more information?  If not, please close out  this question.
Please update and finalize this question.
EE Moderator
Question(s) below appears to have been abandoned. Your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.

To view your open questions, please click the following link(s) and keep them all current with updates.

------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
Thank you everyone.
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
It is requested that any grade less than an A include comments by you as to why.  This not only helps the expert, but others who may now seek this solution in our PAQ database.  If this grade was chosen in error, let me know, I can correct it.  The points to you are always the same, but the expert points granted depend on the grade.

Moondancer - EE Moderator

Explore More ContentExplore courses, solutions, and other research materials related to this topic.