• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can String objects cause outofmemory error?  RSS feed

 
Gautam Bhalla
Ranch Hand
Posts: 30
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As we all know that Strings objects are created in permanent generation area.which is never garbage collected.So,can String objects cause outofmemoryerror?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If they use memory, then of course they can. Also, not all strings go in the string pool..only string literals.
 
drac yang
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
even if we say string constant pool is a dynamic container, if it holds too many strings, say, that occupy the memory more than what the limited memory system underneath could allocate, it surely would.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I understand it, you get an OOM error when you can't get more memory when you need it. So you hit some line of code that basically says "...new(something)". The JVM says "I need X more bytes to create that, but I only have Y available." It really doesn't matter what that new object is, or what's already in memory, the only thing that matters is that you need more memory and the JVM doesn't have it, and can't free anything up.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!