• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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: 23956
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: 9050
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: 23956
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
 
There's a way to do it better - find it. -Edison. A better tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic