• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

String pool and GC

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String a ="Good"
String b = "Moose" ;
String c= a+b;
b = "HI" + b ;
1> c is in the heap and so eligible for gc if set to null Correct me if i am wrong.
2>is b on the String pool or heap?
if i declare
b = a+b;
b= null;
Now is b on the heap or pool? I guess it is on the heap. and it can be GCed (correct me if i am wrong)
what happens to the original string "Moose" which has now no reference to it? Will it also be eligible for GCing?
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rajani,
Detailed discussion on this topic is available here:
http://www.javaranch.com/ubb/Forum24/HTML/000126.html
Regards,
Milind
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic