SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Welcome
• Disclaimer:This presentation is prepared by trainees of
  baabtra as a part of mentoring program. This is not
  official document of baabtra –Mentoring Partner
•   Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt
    . Ltd
Stack and heap
     Ashwin Anand V
     Email:ashwinanand99@gmail.com
     Facebook id:ashwinanand99@gmail.com
Difference between instance
    variables and local variables

• Instance variables are declared inside a class but not
   inside a method:
class Student{
int num;       // num is instance variable
public void showData{}

• Local variables are declared inside a method
   including method arguments:
public void sum(int a){
int x = int a + 3;    // a , x are local variables
•
•   }
What goes inside when you
       declare a variable?
• When you declare a variable in a application, it
  allocates some chunk of memory in the RAM.
• This memory has three things: the name of the
  variable, the data type of the variable, and the value
  of the variable.
STACK

• The Stack section of memory contains methods,
  local variables and reference variables.
• All the information required to resume the execution
  of these functions is stored on the stack.
• Provides static memory allocation
HEAP
• The heap is simply 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 .
Example for stack and heap
public void Method()
 {
int i=4;   (stack memory)
 int y=2    (stack memory)
Class1 cls1= new class(); (heap memory)
}
Example cont….
• If this presentation helped you, please visit
  our page facebook.com/baabtra and like it.
  Thanks in advance.

• www.baabtra.com | www.massbaab.com |ww
  w.baabte.com
Thank you
Stack and Heap

Weitere ähnliche Inhalte

Was ist angesagt?

Python advanced 3.the python std lib by example –data structures
Python advanced 3.the python std lib by example –data structuresPython advanced 3.the python std lib by example –data structures
Python advanced 3.the python std lib by example –data structuresJohn(Qiang) Zhang
 
Cupdf.com introduction to-data-structures-and-algorithm
Cupdf.com introduction to-data-structures-and-algorithmCupdf.com introduction to-data-structures-and-algorithm
Cupdf.com introduction to-data-structures-and-algorithmTarikuDabala1
 
358 33 powerpoint-slides_3-pointers_chapter-3
358 33 powerpoint-slides_3-pointers_chapter-3358 33 powerpoint-slides_3-pointers_chapter-3
358 33 powerpoint-slides_3-pointers_chapter-3sumitbardhan
 
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4sumitbardhan
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructuresNguync91368
 
Intro to plyr for Davis R Users' Group, by Steve Culman
Intro to plyr for Davis R Users' Group, by Steve CulmanIntro to plyr for Davis R Users' Group, by Steve Culman
Intro to plyr for Davis R Users' Group, by Steve CulmanNoam Ross
 
Supporting Arrays and Allocatables in LFortran
Supporting Arrays and Allocatables in LFortranSupporting Arrays and Allocatables in LFortran
Supporting Arrays and Allocatables in LFortranGagandeep Singh
 
Talk on Standard Template Library
Talk on Standard Template LibraryTalk on Standard Template Library
Talk on Standard Template LibraryAnirudh Raja
 
Ppt presentation of queues
Ppt presentation of queuesPpt presentation of queues
Ppt presentation of queuesBuxoo Abdullah
 
Lec16-CS110 Computational Engineering
Lec16-CS110 Computational EngineeringLec16-CS110 Computational Engineering
Lec16-CS110 Computational EngineeringSri Harsha Pamu
 
C Programming : Arrays and Functions
C Programming : Arrays and FunctionsC Programming : Arrays and Functions
C Programming : Arrays and FunctionsSelvaraj Seerangan
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2sumitbardhan
 
358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1sumitbardhan
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocationUTTAM VERMA
 
User defined Functions in MATLAB Part 1
User defined Functions in MATLAB Part 1User defined Functions in MATLAB Part 1
User defined Functions in MATLAB Part 1Shameer Ahmed Koya
 

Was ist angesagt? (20)

Python advanced 3.the python std lib by example –data structures
Python advanced 3.the python std lib by example –data structuresPython advanced 3.the python std lib by example –data structures
Python advanced 3.the python std lib by example –data structures
 
Cupdf.com introduction to-data-structures-and-algorithm
Cupdf.com introduction to-data-structures-and-algorithmCupdf.com introduction to-data-structures-and-algorithm
Cupdf.com introduction to-data-structures-and-algorithm
 
358 33 powerpoint-slides_3-pointers_chapter-3
358 33 powerpoint-slides_3-pointers_chapter-3358 33 powerpoint-slides_3-pointers_chapter-3
358 33 powerpoint-slides_3-pointers_chapter-3
 
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructures
 
2 a stacks
2 a stacks2 a stacks
2 a stacks
 
Intro to plyr for Davis R Users' Group, by Steve Culman
Intro to plyr for Davis R Users' Group, by Steve CulmanIntro to plyr for Davis R Users' Group, by Steve Culman
Intro to plyr for Davis R Users' Group, by Steve Culman
 
Supporting Arrays and Allocatables in LFortran
Supporting Arrays and Allocatables in LFortranSupporting Arrays and Allocatables in LFortran
Supporting Arrays and Allocatables in LFortran
 
2 b queues
2 b queues2 b queues
2 b queues
 
Queues
QueuesQueues
Queues
 
Talk on Standard Template Library
Talk on Standard Template LibraryTalk on Standard Template Library
Talk on Standard Template Library
 
Ppt presentation of queues
Ppt presentation of queuesPpt presentation of queues
Ppt presentation of queues
 
Structure in C
Structure in CStructure in C
Structure in C
 
Lec16-CS110 Computational Engineering
Lec16-CS110 Computational EngineeringLec16-CS110 Computational Engineering
Lec16-CS110 Computational Engineering
 
C Programming : Arrays and Functions
C Programming : Arrays and FunctionsC Programming : Arrays and Functions
C Programming : Arrays and Functions
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2
 
358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
 
Python recursion
Python recursionPython recursion
Python recursion
 
User defined Functions in MATLAB Part 1
User defined Functions in MATLAB Part 1User defined Functions in MATLAB Part 1
User defined Functions in MATLAB Part 1
 

Ähnlich wie Stack and Heap

static members in object oriented program.pptx
static members in object oriented program.pptxstatic members in object oriented program.pptx
static members in object oriented program.pptxurvashipundir04
 
lecture-18staticdatamember-160705095116.pdf
lecture-18staticdatamember-160705095116.pdflecture-18staticdatamember-160705095116.pdf
lecture-18staticdatamember-160705095116.pdfAneesAbbasi14
 
Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1Sachintha Gunasena
 
class as the basis.pptx
class as the basis.pptxclass as the basis.pptx
class as the basis.pptxEpsiba1
 
Artificial Intelligence Course: Linear models
Artificial Intelligence Course: Linear models Artificial Intelligence Course: Linear models
Artificial Intelligence Course: Linear models ananth
 
C MEMORY MODEL​.pptx
C MEMORY MODEL​.pptxC MEMORY MODEL​.pptx
C MEMORY MODEL​.pptxSKUP1
 
C MEMORY MODEL​.pptx
C MEMORY MODEL​.pptxC MEMORY MODEL​.pptx
C MEMORY MODEL​.pptxLECO9
 

Ähnlich wie Stack and Heap (20)

Stack&heap
Stack&heapStack&heap
Stack&heap
 
Stack n heap
Stack n heapStack n heap
Stack n heap
 
Stack and heap
Stack and heapStack and heap
Stack and heap
 
Functions with heap and stack
Functions with heap and stackFunctions with heap and stack
Functions with heap and stack
 
static members in object oriented program.pptx
static members in object oriented program.pptxstatic members in object oriented program.pptx
static members in object oriented program.pptx
 
STORAGE CLASS.pptx
STORAGE CLASS.pptxSTORAGE CLASS.pptx
STORAGE CLASS.pptx
 
[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member
 
lecture-18staticdatamember-160705095116.pdf
lecture-18staticdatamember-160705095116.pdflecture-18staticdatamember-160705095116.pdf
lecture-18staticdatamember-160705095116.pdf
 
Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1
 
Function with heap and stack
Function with heap and stackFunction with heap and stack
Function with heap and stack
 
L4. Ensembles of Decision Trees
L4. Ensembles of Decision TreesL4. Ensembles of Decision Trees
L4. Ensembles of Decision Trees
 
class as the basis.pptx
class as the basis.pptxclass as the basis.pptx
class as the basis.pptx
 
Artificial Intelligence Course: Linear models
Artificial Intelligence Course: Linear models Artificial Intelligence Course: Linear models
Artificial Intelligence Course: Linear models
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
C MEMORY MODEL​.pptx
C MEMORY MODEL​.pptxC MEMORY MODEL​.pptx
C MEMORY MODEL​.pptx
 
C MEMORY MODEL​.pptx
C MEMORY MODEL​.pptxC MEMORY MODEL​.pptx
C MEMORY MODEL​.pptx
 
Oop concept
Oop conceptOop concept
Oop concept
 
Java
JavaJava
Java
 
Constructors and Method Overloading
Constructors and Method OverloadingConstructors and Method Overloading
Constructors and Method Overloading
 
Stack and heap
Stack and heapStack and heap
Stack and heap
 

Mehr von baabtra.com - No. 1 supplier of quality freshers

Mehr von baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Stack and Heap

  • 2. • Disclaimer:This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner • Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 3. Stack and heap Ashwin Anand V Email:ashwinanand99@gmail.com Facebook id:ashwinanand99@gmail.com
  • 4. Difference between instance variables and local variables • Instance variables are declared inside a class but not inside a method: class Student{ int num; // num is instance variable public void showData{} • Local variables are declared inside a method including method arguments: public void sum(int a){ int x = int a + 3; // a , x are local variables • • }
  • 5. What goes inside when you declare a variable? • When you declare a variable in a application, it allocates some chunk of memory in the RAM. • This memory has three things: the name of the variable, the data type of the variable, and the value of the variable.
  • 6. STACK • The Stack section of memory contains methods, local variables and reference variables. • All the information required to resume the execution of these functions is stored on the stack. • Provides static memory allocation
  • 7. HEAP • The heap is simply 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 .
  • 8. Example for stack and heap public void Method() { int i=4; (stack memory) int y=2 (stack memory) Class1 cls1= new class(); (heap memory) }
  • 10. • If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. • www.baabtra.com | www.massbaab.com |ww w.baabte.com