Stack n heap

587 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
587
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Stack n heap

  1. 1. Disclaimer: This presentation is prepared bytrainees of baabtra as a part of mentoringprogram. This is not official document of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte SystemTechnologies Pvt . Ltd
  2. 2. HEAP AND STACK vishnu.padinjattedath@gmail.com @Vishnu_Kishor
  3. 3. BASICS• The JVM divided the memory into following sections. – Heap – Stack – Code – Static• This division of memory is required for its effective management
  4. 4. • The code section contains your bytecode.• The Stack section of memory contains methods, local variables and reference variables.• The Heap section contains Objects (may also contain reference variables).• The Static section contains Static data/methods.
  5. 5. • Of all of the above 4 sections, you need to understand the allocation of memory in Stack & Heap the most, since it will affect your programming efforts.
  6. 6. Difference between instance variables and local variables• Instance variables are declared inside a class but not inside a method class Student{ <strong>int num; // num is instance variable</strong> public void showData{}
  7. 7. • Local variables are declared inside a method including method arguments. 1public void sum(int a) { int x = int a + 3; // a , x are local variables</strong> }
  8. 8. VARIABLE DECLARATION• Allocation of some RAM memory to variable.• Three aspects saved in memory – the name of the variable, – the data type of the variable and – the value of the variable.
  9. 9. STACK : DEFENITION• The Stack section contains – methods, – local variables and – reference variables.• The info: required to resume the execution of these functions is stored in the stack.• Provides static memory allocation
  10. 10. HEAP : DEFENITION• The memory used by programs to store global variables.• All global variables are stored in heap memory• When that function exits, the heap memory used by each local variable is freed.• Dynamic memory allocation
  11. 11. Thank you
  12. 12. Did this presentation help you??? do visit our page facebook.com/baabtra and like us.www.baabtra.com |www.massbaab.com |www.baabte.com |
  13. 13. Contact Us

×