• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String Pool

 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i have got a doubt. & that is
when are the objects in the string pool garbage collected?
for example
.
.
String a = "literal_1"; //1
String b = "literal_2"; //2
a = null; //3
b = null; //4
.
.
..
whether the literals in line 1 & 2 are eligible for gc after line 4 has executed.
i feel they are not eligible for gc since they are in string pool. but that raises my doubt that when they will be gced.because if i keep on creating literals then my program will run out of memory if gc won't claim the string pool?
thanx in advance
deekasha



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic