answersLogoWhite

0

Objects are stored in an area of memory called the "heap", whilst reference variables are stored in the "stack". These are both parts of the computer's RAM memory; the Java Virtual Machine (JVM) simply reserves part of the memory available to it for the stack and for the heap, and manages them accordingly.

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

What are objects in java?

Object is like a variable of the class type which references the memory required by the attributes of the class.


What is memory leak problemin java?

Memory leaks do not occur in Java as the garbage collector clears the memory which has no references.


What is a heap in Java and how does it function within the Java programming language?

In Java, a heap is a data structure used to store and manage objects dynamically allocated during program execution. It is a region of memory where objects are stored and accessed by the Java Virtual Machine (JVM). The heap is responsible for memory allocation and deallocation, allowing objects to be created and destroyed as needed. This helps manage memory efficiently and ensures that the program runs smoothly without running out of memory.


Can a Java application have memory leak?

Java has a fairly sophisticated garbage collection system, and in general you don't worry about memory leaks, as they only happen in a few very specific circumstances (notably, when adding listeners to Swing GUI objects and not removing them). If you need more sophistcated memory management, java provides the clases in the java.lang.ref package.


Who is allocated by java memory?

Objects, mainly.


2 What is the purpose of garbage collection in java and when is it used?

Garbage collection prevents memory leaks. In Java, the Java Virtual Machine will garbage collect whenever there is memory that has no references.


What is phantom memory in java?

Phantom memory is a false memory which doesnt exist in reality .These references are available to collect byGC


How you allocate the memory in java?

In Java we need not allocate memory manually. The JVM would take care of allocating as much memory that your objects would require automatically.


What are the differences between C and Java reference variables?

Java does not have the concept of Reference Variables. We cannot access the memory location where the data is stored in Java.


Give the brief introduction of garbage collection?

Garbage collection in java is nothing but the process of freeing up unused memory from the JVM memory heap. Every time an object is created, it is allocated some space in the memory. Once the use for that object is over, that memory space needs to be released so that it can be used by other objects. In Java, this process is automated and the JVM takes care of doing this. Once in a while, a program that performs this garbage collection runs and frees up memory for other objects to use. All objects whose references are no longer used are cleared.


What is GC in java?

GC stands for garbage collector - this is the mechanism which cleans up unused object references. The GC is why memory management in Java is almost non-existent.


In Java where do instance variables stored in memory?

An instance variable is part of an object. Therefore, it gets stored together with the object, on the heap. The heap is the part of memory which is used to store objects.An instance variable is part of an object. Therefore, it gets stored together with the object, on the heap. The heap is the part of memory which is used to store objects.An instance variable is part of an object. Therefore, it gets stored together with the object, on the heap. The heap is the part of memory which is used to store objects.An instance variable is part of an object. Therefore, it gets stored together with the object, on the heap. The heap is the part of memory which is used to store objects.