• Post Reply Bookmark Topic Watch Topic
  • New Topic

garbage collection  RSS feed

 
arun sasidharan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
will java garbage collection ensure that my program will never run short of memory, no matter what ever i code?
 
Yuriy Grechukhin
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, garbage collection ensures that the memory will be clean of objects you don't reference any more. If you create enough objects in memory and keep a reference to all of them, you will surely get java.lang.OutOfMemoryError and your program will terminate. But if you create the same amount of objects and loose references to them, you won't get that error, since they will be garbage collected.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!