JVM Memory Management (2)

haimei
play-hard-work-hard
2 min readApr 21, 2016

This is a study note from “Everything I Ever Learned about JVM Performance Tuning @Twitter”.

  • Adaptive Sizing Policy:
    Throughput collectors an automatically tune themselves:
  • -XX:+UseAdaptiveSizePolicy
  • -XX:+MaxGCPauseMillis=…(i.e. 100)
  • -XX:+GCTimeRatio=…(i.e. 19)
  • tune young generation tool:
  • enable -XX:+PrintGCDetails, -XX:+PrintHeapAtGC, and -XX:+PrintTenuringDistribution
  • watch survivor size
  • watch the tenuring threshold; it might need to tune it to tenure long lived objects faster.
  • some rules:
  • Too many live objects during young generation GC:
    Reduce NewSize, reduce survivor spaces, reduce tenuring threshold.
  • Too many threads:
    Find the minimal concurrency level, or split the service into serval JVMs.
  • Eden should be big enough to hold more than one times transactions. In this case, there is no stop-the-world and through output would be big.
  • Each survivor should be big enough to maintain alive objects and aged objects.
  • Increasing threshold will put long aged objects to old generation asap to release more space to survivor.
  • Now we use 64-bit JVM, 64-bit pointer will cause CPU buffer is smaller than 32-bit pointer. Involving -XX:+UseCompressedOops will compress 64-bit pointer to 32-bit pointer, but it still will use 64-bit memory space.
    Object stored in memory split into 3 parts:
  • header: mark word + klass pointer
  • mark word stores running data for object itself.
  • klass pointer points to the object’s class metadata.
  • instance data:
Screenshot 2016-04-21 11.14.09
  • padding: 0 <= padding <= 8
    (header + instance data + padding) % 8 == 0

--

--