Skip to main content
Question Protected by Stephen C
added 13 characters in body; edited title
Source Link
dimo414
  • 49.3k
  • 19
  • 167
  • 273

What type of memory (Heap or Stack) Where does Java's String constant pool in Java gets storedlive, the heap or the stack?

I know the concept of constanta constants pool and the String constant pool used by JVMs to handle String literals. But I have a doubt that whatdon't know which type of memory is used by the JVM to store String constant literals. StackThe stack or Heap?the heap? Since its a literal which is not associated with any instance I canwould assume that it will be stored in Stackstack. But uponif it's not referred by any instance the literal has to be collected by GC run (Correctcorrect me if I am wrong here :( ), so how that is that handled if itsit is stored in Stack.the stack?

What type of memory (Heap or Stack) String constant pool in Java gets stored?

I know the concept of constant pool and String constant pool used by JVMs to handle String literals. But I have a doubt that what type of memory is used by JVM to store String constant literals. Stack or Heap?? Since its a literal which is not associated with any instance I can assume that it will be stored in Stack. But upon not referred by any instance the literal has to be collected by GC run (Correct me if I am wrong here :( ), so how that is handled if its stored in Stack.

Where does Java's String constant pool live, the heap or the stack?

I know the concept of a constants pool and the String constant pool used by JVMs to handle String literals. But I don't know which type of memory is used by the JVM to store String constant literals. The stack or the heap? Since its a literal which is not associated with any instance I would assume that it will be stored in stack. But if it's not referred by any instance the literal has to be collected by GC run (correct me if I am wrong), so how is that handled if it is stored in the stack?

deleted 52 characters in body; edited tags
Source Link
Tomasz Nurkiewicz
  • 342.1k
  • 72
  • 713
  • 680

I know the concept of constant pool and String constant pool used by JVMs to handle String literals. But I have a doubt that what type of memory is used by JVM to store String constant literals. Stack or Heap?? Since its a literal which is not associated with any instance I can assume that it will be stored in Stack. But upon not referred by any instance the literal has to be collected by GC run (Correct me if I am wrong here :( ), so how that is handled if its stored in Stack.

Thanks in advance.

By, Rengasami Ramanujam

I know the concept of constant pool and String constant pool used by JVMs to handle String literals. But I have a doubt that what type of memory is used by JVM to store String constant literals. Stack or Heap?? Since its a literal which is not associated with any instance I can assume that it will be stored in Stack. But upon not referred by any instance the literal has to be collected by GC run (Correct me if I am wrong here :( ), so how that is handled if its stored in Stack.

Thanks in advance.

By, Rengasami Ramanujam

I know the concept of constant pool and String constant pool used by JVMs to handle String literals. But I have a doubt that what type of memory is used by JVM to store String constant literals. Stack or Heap?? Since its a literal which is not associated with any instance I can assume that it will be stored in Stack. But upon not referred by any instance the literal has to be collected by GC run (Correct me if I am wrong here :( ), so how that is handled if its stored in Stack.

Source Link

What type of memory (Heap or Stack) String constant pool in Java gets stored?

I know the concept of constant pool and String constant pool used by JVMs to handle String literals. But I have a doubt that what type of memory is used by JVM to store String constant literals. Stack or Heap?? Since its a literal which is not associated with any instance I can assume that it will be stored in Stack. But upon not referred by any instance the literal has to be collected by GC run (Correct me if I am wrong here :( ), so how that is handled if its stored in Stack.

Thanks in advance.

By, Rengasami Ramanujam