JavaGian java tutorial and java interview question and answer

JavaGian , Free Online Tutorials, JavaGian provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, ajax, core java, sql, python, php, c language etc. for beginners and professionals.

Showing posts with label Heap. Show all posts
Showing posts with label Heap. Show all posts

Difference between Heap and Stack Memory in Java JVM ?

3:31 AM
Difference between Heap and Stack Memory in Java JVM Heap memory is shared by all threads of Java application but Stack memory is local to each thread.  Objects are created in heap memory but method frames are stored in Stack memory, and size of heap space is much bigger than the small size of Stack in Java Stack vs Heap in Java As I told, both Stack and Heap space are part of JVM but they are used for different purpose, let's see some more points to understand the difference between stack and heap memory better. 1) Size One of the significant difference between Stack and heap comes from their size. Heap space in Java is much bigger than the Stack memory. This is partly due to the fact that whenever a new thread is created in JVM, a separate stack memory is allocated to them. 2) Resizing JVM allows you to resize both heap and stack in Java, though you need to use different JVM flags for that. You can use -Xms and -Xmx to specify the starting and maximum he

.