• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Stack & Heap

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stack stores non-static variables & Heap stores Object's

1) Where do Stack & Heap are ? in terms of Hardware ie in RAM or Cache ?
2) How Heap is faster then Stack ?
3) Where does static variable store ? In RAM or Cache Memory or any registers ?
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kamal Trivedi:
Stack stores non-static variables & Heap stores Object's

1) Where do Stack & Heap are ? in terms of Hardware ie in RAM or Cache ?
2) How Heap is faster then Stack ?
3) Where does static variable store ? In RAM or Cache Memory or any registers ?



The stack is for local variables. The heap is for objects. (with Java 6 and later, this changes somewhat, but that will just confuse stuff)

1. The stack and heap are just in different memory areas. In terms of hardware, they use the same hardware.

2. Well, maybe one is faster, as they are likely to use different machine instructions. And implementation is different, but...

3. As mentioned. Same hardware. Just different areas of memory.

Henry
 
Kamal Trivedi
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Henry for your answer.

Doubt :- If they are in same hardware(memory area),then how they work differently(Not of Machine Instruction). Is stack & Heap are Logical concept.
 
author
Posts: 9046
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just a side note - these questions aren't on the exam..

carry on
 
Henry Wong
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Agreed. This is definitely not on the exam.

However, if you would like to dive into details of how call stacks (and how processors) work, I would recommend taking a computer architecture course. An assembly language programming course would do some good here too.

Henry
 
Can you smell this for me? I think this tiny ad smells like blueberry pie!
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic