This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage collection Question

 
Dinesh Tahiliani
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need little advise on Garbage collection,

I have heard that whenever the gc process is running, we try to do some other process, it will not execute unless the gc process is complete.

Please let me know if iam correct or wrong.
If wrong, need little details and explaination on the same.
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dinesh,

the garbage collector of Java runs as a background daemon in a special thread whenever the JVM is started. Of course it regularly has to do it's job so it obviously consumes resources like CPU power. On a single processor system it's clear that there's no chance for other threads to proceed if the garbage collector thread is active because there's no real multi threading on such system. But unlike earlier version of Java and the JVM the garbage collector is really, really clever and you don't notice it doing its work in normal applications. It would be no problem to provoke lags in your program flow by allocation and deallocation enormous amounts of memory without sense but this would also lead to inefficiencies in programming languages without garbage collector.

Marco
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic