• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to remove strings from String constant pool ?  RSS feed

 
Jay Pawar
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
Is there a way to remove the strings (declared by my program) stored in String constant pool ?

TIA
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. I've heard, however, that modern JVMs use a "WeakHashMap" from which unused constants can be garbage-collected if necessary.
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given that Java is a garbage collected environment, you cannot destroy any objects. However, you can make objects available for garbage collection, including string constants.

http://jqa.tmorris.net/GetQAndA.action?qids=68&showAnswers=true
 
Jay Pawar
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ernest and Tony for your responses. By the way, Tony, excellent explanation on that FAQ# 45
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!