Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
docu...
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 ...
Stack & heap memory

Waseem hassan
wazeeem456@gmail.com
www.facebook.com/waseem
hassan
twitter.com/username
in.linkedin.co...
Stack
• The stack is a place in the computer memory
where all the variables that are declared and
initialized before runti...
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...
Example-stack overflow
• Example For Stack overflow
#include <stdio.h>
int main()
{
int nStack[100000000];
return 0;
}
• C...
Heap
• Heap is an area of memory used for dynamic
memory allocation.
• The heap is the memory used by program to
store glo...
Heap
• Any data on the heap will remain there until
it’s manually deleted by the programmer.
• If the current size of the ...
Heap
• To allocate memory – malloc(),calloc() or
realloc()
• To deallocate memory-free()[memory leak]
• Does not have size...
Example:malloc(),realloc(),free()
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

#include <stdio.h>
#include <stdlib.h>
int main()
{
char ...
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.c...
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550

Start up Vil...
Stack and heap
Upcoming SlideShare
Loading in …5
×

Stack and heap

360 views

Published on

Stack and heap

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
360
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Stack and heap

  1. 1. 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
  2. 2. Typing Speed Week Target Achieved 1 21 19 2 24 21 3 25 22 4 25 23
  3. 3. 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
  4. 4. Stack & heap memory Waseem hassan wazeeem456@gmail.com www.facebook.com/waseem hassan twitter.com/username in.linkedin.com/in/waseemh assan 9567850028
  5. 5. 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.
  6. 6. stack • In stack , data is added or removed in Last-infirst-out manner(LIFO)
  7. 7. 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.
  8. 8. Example-stack overflow • Example For Stack overflow #include <stdio.h> int main() { int nStack[100000000]; return 0; } • Causes stack overflow • Program will crash
  9. 9. 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.
  10. 10. 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.
  11. 11. 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
  12. 12. 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); }
  13. 13. Example : stack and heap public void Method1() { int i=4; int y=2; class1 cls1 = new class1(); }
  14. 14. Example : stack and heap
  15. 15. 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
  16. 16. 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

×