2

Someone said that old generation takes more space than young generation in java virtual machine, is it right? I have not found any article about the topic on the Internet.

Any help is highly appreciated!

GGG
  • 241
  • 2
  • 5
  • possible duplicate of [Java heap terminology: young, old and permanent generations?](http://stackoverflow.com/questions/2129044/java-heap-terminology-young-old-and-permanent-generations) – Ajoy Jul 14 '15 at 10:14
  • Even if it does (or doesn't), why would it matter to you? Or put differently: what insight would you expect to gain from an answer. – the8472 Jul 14 '15 at 12:05
  • Thank you for Java heap terminology:.... , it is helpful to me. I am curious about it, and want to find out the truth . – GGG Jul 15 '15 at 05:30
  • I usually tune the old space to be much smaller than the young space. You can set it anyway but the default assume that you don't need much space for short live objects and you may need to accumulate more/larger long lived objects. – Peter Lawrey Jul 17 '15 at 17:00

1 Answers1

0

The ratio between the size of generations in the JVM is a trade-off between different factors.

See “Non-Standard Options” of the java launcher tool:

-Xmnsize

Sets the initial and maximum size (in bytes) of the heap for the young generation (nursery). …

The young generation region of the heap is used for new objects. GC is performed in this region more often than in other regions. If the size for the young generation is too small, then a lot of minor garbage collections will be performed. If the size is too large, then only full garbage collections will be performed, which can take a long time to complete. Oracle recommends that you keep the size for the young generation between a half and a quarter of the overall heap size.

So the ratio is not fixed but tunable. It doesn’t even have to be a constant, as you can set minimum and maximum sizes for the young generation using -XX:NewSize, resp. -XX:MaxNewSize. But the recommendation is indeed to have a young generation which is smaller than the old generation and I expect the default values to follow it.

Community
  • 1
  • 1
Holger
  • 285,553
  • 42
  • 434
  • 765