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
Typing Speed
Week

Target Achieved

1

21

19

2

24

21

3

25

22

4

25

23
Jobs Applied
#

Company

Designation

Applied Date

1

cs3Infomat Pvt. Ltd

Software trainee

13-9-2013

2

Big leap

Web designers

17-9-2013

3

Current Status
Stack & heap memory

Waseem hassan
wazeeem456@gmail.com
www.facebook.com/waseem
hassan
twitter.com/username
in.linkedin.com/in/waseemh
assan
9567850028
Stack
• The stack is a place in the computer memory
where all the variables that are declared and
initialized before runtime are stored.
• It is a temporary storage memory, if you come
out of the program the memory of the
variable will not be there.
• Any data on the stack for a function will
automatically be deleted.
stack
• In stack , data is added or removed in Last-infirst-out manner(LIFO)
stack
• The stack has a fixed size
• Both stack and heap are stored on the RAM
• If there is not enough space on the stack to
handle the memory being assigned to it, a
stack overflow occurs.
Example-stack overflow
• Example For Stack overflow
#include <stdio.h>
int main()
{
int nStack[100000000];
return 0;
}
• Causes stack overflow
• Program will crash
Heap
• Heap is an area of memory used for dynamic
memory allocation.
• The heap is the memory used by program to
store global variables.
• Variables on the heap must be destroyed
manually.
Heap
• Any data on the heap will remain there until
it’s manually deleted by the programmer.
• If the current size of the heap is too small to
accommodate new memory, then more
memory can be added to the heap by the
operating system.
Heap
• To allocate memory – malloc(),calloc() or
realloc()
• To deallocate memory-free()[memory leak]
• Does not have size restrictions on variable size
• Heap memory is slower than stack
Example:malloc(),realloc(),free()
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

#include <stdio.h>
#include <stdlib.h>
int main()
{
char *str;
/* Initial memory allocation */
str = (char *) malloc(15);
strcpy(str, “ABC");
printf("String = %s, Address = %un", str, str);
/* Reallocating memory */
str = (char *) realloc(str, 25);
strcat(str, ".com");
printf("String = %s, Address = %un", str, str);
free(str);
return(0);
}
Example : stack and heap
public void Method1()
{
int i=4;
int y=2;
class1 cls1 = new class1();
}
Example : stack and heap
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.

Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550

Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550

Stack and heap

  • 2.
    Disclaimer: This presentationis 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.
  • 4.
    Jobs Applied # Company Designation Applied Date 1 cs3InfomatPvt. Ltd Software trainee 13-9-2013 2 Big leap Web designers 17-9-2013 3 Current Status
  • 5.
    Stack & heapmemory Waseem hassan wazeeem456@gmail.com www.facebook.com/waseem hassan twitter.com/username in.linkedin.com/in/waseemh assan 9567850028
  • 6.
    Stack • The stackis a place in the computer memory where all the variables that are declared and initialized before runtime are stored. • It is a temporary storage memory, if you come out of the program the memory of the variable will not be there. • Any data on the stack for a function will automatically be deleted.
  • 7.
    stack • In stack, data is added or removed in Last-infirst-out manner(LIFO)
  • 8.
    stack • The stackhas a fixed size • Both stack and heap are stored on the RAM • If there is not enough space on the stack to handle the memory being assigned to it, a stack overflow occurs.
  • 9.
    Example-stack overflow • ExampleFor Stack overflow #include <stdio.h> int main() { int nStack[100000000]; return 0; } • Causes stack overflow • Program will crash
  • 10.
    Heap • Heap isan area of memory used for dynamic memory allocation. • The heap is the memory used by program to store global variables. • Variables on the heap must be destroyed manually.
  • 11.
    Heap • Any dataon the heap will remain there until it’s manually deleted by the programmer. • If the current size of the heap is too small to accommodate new memory, then more memory can be added to the heap by the operating system.
  • 12.
    Heap • To allocatememory – malloc(),calloc() or realloc() • To deallocate memory-free()[memory leak] • Does not have size restrictions on variable size • Heap memory is slower than stack
  • 13.
    Example:malloc(),realloc(),free() • • • • • • • • • • • • • • • #include <stdio.h> #include <stdlib.h> intmain() { char *str; /* Initial memory allocation */ str = (char *) malloc(15); strcpy(str, “ABC"); printf("String = %s, Address = %un", str, str); /* Reallocating memory */ str = (char *) realloc(str, 25); strcat(str, ".com"); printf("String = %s, Address = %un", str, str); free(str); return(0); }
  • 14.
    Example : stackand heap public void Method1() { int i=4; int y=2; class1 cls1 = new class1(); }
  • 15.
  • 16.
    If this presentationhelped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 17.
    Contact Us Emarald Mall(Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550