• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

garbage collection

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The objects those have no more reference or set to null are garbage collected.
Is there any specific rule for String objects which are created by new String statement to be garbage collected.Because it creates two objects one in the heap and one in the pool.
And how the String LITERALS are garbage collected.
Someone please explain.
Thank you.
mita
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mita,
The objects that are new'ed, are created on the Heap and are garbage collected using the 'zero reference' rule. This is an important concept for SCJP, so make sure you understand it well.
The objects created in the String pool are not subjected to GC until the class is unloaded by the JVM. They get discarded at the time, or just before the virtual machine unloads the class bytecode. For the purpose of the SCJP exam, you are not required to know the details of String pool memory management.
Hope this helps,
Ajith
 
mita
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ajith, I appreciate it.
mita
 
Lookout! Runaway whale! Hide behind this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic