Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Java look like in memory

Tags:

java

memory

I am new to java and still learning. I got my head around inner and anonymous classes. Now I have a technical question about how java looks like in memory, when allocating objects, defining classes, etc.

Like what does memory look like when I have a field that is an object that is defined in an outside class vs an inner class. Do static classes look different than non static?

I just need a visual reference.

Thanks Guys

like image 636
pp. Avatar asked Jan 30 '10 23:01

pp.


People also ask

How is a Java object represented in memory?

In Java, all objects are dynamically allocated on Heap. This is different from C++ where objects can be allocated memory either on Stack or on Heap. In C++, when we allocate the object using new(), the object is allocated on Heap, otherwise on Stack if not global or static.

Where Java objects are stored in in memory?

Heap space is used for the dynamic memory allocation of Java objects and JRE classes at runtime. New objects are always created in heap space, and the references to these objects are stored in stack memory.

What is memory layout in Java?

A memory layout can be used to describe the contents of a memory segment in a language neutral fashion.

How does Java manage its memory?

Memory Management in Java refers to allocating and deallocating memory to java objects which reside in areas called Stack and Heap. Java has an automatic memory deallocation system known as Garbage Collector.


1 Answers

Helpful link

http://www.artima.com/insidejvm/ed2/jvm6.html

like image 184
pp. Avatar answered Oct 04 '22 19:10

pp.