Author Topic: hotspot JVM garbage collection strategy?  (Read 7567 times)

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
hotspot JVM garbage collection strategy?
« on: August 14, 2016, 08:47:58 am »
in my JPCT app, i use constant framerate(30fps) by adding Thread.sleep at the end of each frame update. as long as the time needed for each frame update doesn't exceed 0.033333 sec, the app runs well.
but if a full gc is performed, a frame will be delayed, and i can't predict when a gc will be performed.
is there any gc mode that does gc "little by little" so every gc doesn't take longer than... say 0.015 sec ?
can gc be performed when my main thread sleeps?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: hotspot JVM garbage collection strategy?
« Reply #1 on: August 14, 2016, 11:26:25 am »
You can enable all kinds of GC modes. I don't remember their names, but there are ones that run in parallel to the main thread. Just google it, Oracle has some documentation on it. Apart from that, GC shouldn't be noticable in most cases. Maybe a more precise measuring would help, i.e. calculate a dynamic sleep value.

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
Re: hotspot JVM garbage collection strategy?
« Reply #2 on: August 14, 2016, 12:51:08 pm »
i do have a dynamic sleep system, i haven't noticed gc slowdown yet - my current average CPU time is at about 30%, but i am afraid when the program gets more complicated and CPU time gets to 70% or more, gc may be noticeable.
and it can cause more trouble if i have multiplayer features - lost of data sync & prediction error. it's a far future for me though.
i have quad-core CPU, i hope the parallel gc is real good.
thanks anyway.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: hotspot JVM garbage collection strategy?
« Reply #3 on: August 14, 2016, 01:54:24 pm »
I've never experienced GC to be a problem on desktop. On Android it's another story though.