Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

garbage collection

 
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.
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!