Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

heap, perm gem, and stack

$
0
0
I have an exam coming up and I am having a difficult time getting my head around the portion of material dealing with memory (heap, perm gem, and stack). This is a few study guide material and questions my professor gave me.

The following link is where I get my information from
http://www.cs.umd.edu/class/spring2013/cmsc131-23/Notes/2013-02-25-Trace.htm
When you look at the link what is the circle with name ident and token level soppuse to be?


1, Draw the memory map (including the "variable stack" and the "heap") for the following code fragment:
double x = 7.9;
double y = x;
String q = new String("Cat");
String r = q;
String s = new String®;

I cannot upload the picture so Ill just explain what I have

Stack
------
s---------------------(String)---------->®
r-----------------------\/
q------------------> (String)--------> (cat)
y = 7.9
x = 7.9


x= 7.9 is in the stack
y = 7.9 which is also in the stack
q refers to a string (I think is in PermGem) which then refers to cat (in what I think is in heap)
r refers to the same string as q (Again i think is PerGem) which then refers to cat (in what I think is in heap)
s refers to a string(Different from q and r) which refers to (r which I think is in the Heap)

****If I AM WRONG ABOUT STRING BEING IN PERMGEM OR CAT AND R BEING IN HEAP OR ANYTHING ELSE PLEASE LET ME KNOW.

2, What is actually stored in the variable "q" in the previous question?
The answer is the following:
q holds the memory location of where the String "cat" is in RAM
My question is:
I do not understand what Ram has anything to do with it
What is in Ram is the stack per gem or heap in ram?


Thank you so much for your help

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>