• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

GC and Timer

 
Greenhorn
Posts: 17
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Experts,
I was trying to build an application (which will run in a JEE environment) where I have a LinkedBlockingQueue and some data get added. I try to empty this queue on two conditions 1-> when queue is full 2-> when there is a time out. I start a timer when i add the first element and reset i empty the queue. Question bothering me is, is there any side effect on the running timer when the stop-the-world GC runs? If so then what is is and what is the alternative?
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, GC runs in a different thread. It doesn't pause anything. Maybe the fact that it takes up processor time will affect the resolution of the timer, but it should hardly bother you.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:As far as I know, GC runs in a different thread. It doesn't pause anything. Maybe the fact that it takes up processor time will affect the resolution of the timer, but it should hardly bother you.



The newpar generation collector is parallel -- and not concurrent... So it will "stop-the-world". The concurrent tenure generation collector is concurrent, meaning not stop-the-world, but under very high throughput and heap, it can fail. This will cause the standard old generation gc to run, which will "stop-the-world". Personally, I wouldn't worry about it too much, as the collector is fairly quick, unless you are talking about about a heap greater than 4gig with allocation rates in the hundreds of megs per second.

So, the timer may be late to start. Its "stop-the-world", everything will be frozen during this period.

Henry


 
Stephan van Hulst
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Henry, could you elaborate on this a bit? What are these different collectors you talk of? I'm familiar with mark and sweep, but not with the terms you mentioned.
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Henry, could you elaborate on this a bit? What are these different collectors you talk of? I'm familiar with mark and sweep, but not with the terms you mentioned.



Sure...

A mark and sweep collector does collection in multiple passes. It traverses the heap and mark everything that is reachable; and then in later passes, it compacts the heap. This pass is the sweep part. Objects are moved only to fill gaps left by unreachable objects.

The other type of collector is the copy collector. It does collection by moving everything that is reachable. The heap is cut in half, and objects are moved from half to half during each cycle. What doesn't move is collected.


A generational collector is not really a collector. It is a technique of using multiple collectors. A new object is placed in a "new" heap, where it is managed by a collector. And if it survives too many cycles, it gets promoted to the tenured heap, where it is managed by another collector. With the Sun JVM, the new generation is a copy collector and the tenured generation is a mark and sweep collector.


Other terms....

"Parallel" means that the collector is threaded -- and will use many processors. "Concurrent" means that the collector will run concurrently with the application. If the collector is not concurrent, it will stop-the-world (the application) until it is finished. Of all the JVMs available today, there is only one GC that is both concurrent and parallel; and that is the Azul JVM.


The Sun JVM actually have many collectors. There are quite a few options for both the new and old generational heaps.

Henry
 
Harsha Hegde
Greenhorn
Posts: 17
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Stephan and Henry. Henry's reply worried me a bit. what i infer is in a high load system no timer application is reliable is this true, how is it managed then?
 
I'm doing laundry! Look how clean this tiny ad is:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic