# How to reproduce
we got this exception when getting `MemoryUsage` via mxbean
```
Exception in thread "main" java.lang.IllegalArgumentException: committed = 503382016 should be < max = 503316480
at java.lang.management.MemoryUsage.<init>(MemoryUsage.java:160)
at sun.management.MemoryPoolImpl.getCollectionUsage0(Native Method)
at sun.management.MemoryPoolImpl.getCollectionUsage(MemoryPoolImpl.java:266)
at Test.main(Test.java:11)
```
The test case is quite simple,
```
public class Test {
public static void main(String[] args) throws Exception {
System.gc();
List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
for (MemoryPoolMXBean pool : pools) {
System.out.println(pool.getName());
System.out.println(pool.getCollectionUsage());
}
}
}
```
and java command is `-XX:+UseSerialGC -Xms600m -Xmn600m`
# Why this happen
We know the computation of eden/survivor size is
```
survivor_size = align_down(young_gen_size / (SurvivorRatio + 2))
eden_size = young_gen_size - (2*survivor_size)
```
Under certain circumstances, the aligning down here will make `survivor_committed_size` to decrease more than expected, causing `eden_committed_size` to soar above `eden_max_size`. And all this leads to the exception wo got here: committed = 503382016 should be < max = 503316480
# How to Fix
A simple work-around for this issue is checking whether eden committed size is more than its max size. If so, set a minimum committed size for survivor, and recompute eden size accordingly.
we got this exception when getting `MemoryUsage` via mxbean
```
Exception in thread "main" java.lang.IllegalArgumentException: committed = 503382016 should be < max = 503316480
at java.lang.management.MemoryUsage.<init>(MemoryUsage.java:160)
at sun.management.MemoryPoolImpl.getCollectionUsage0(Native Method)
at sun.management.MemoryPoolImpl.getCollectionUsage(MemoryPoolImpl.java:266)
at Test.main(Test.java:11)
```
The test case is quite simple,
```
public class Test {
public static void main(String[] args) throws Exception {
System.gc();
List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
for (MemoryPoolMXBean pool : pools) {
System.out.println(pool.getName());
System.out.println(pool.getCollectionUsage());
}
}
}
```
and java command is `-XX:+UseSerialGC -Xms600m -Xmn600m`
# Why this happen
We know the computation of eden/survivor size is
```
survivor_size = align_down(young_gen_size / (SurvivorRatio + 2))
eden_size = young_gen_size - (2*survivor_size)
```
Under certain circumstances, the aligning down here will make `survivor_committed_size` to decrease more than expected, causing `eden_committed_size` to soar above `eden_max_size`. And all this leads to the exception wo got here: committed = 503382016 should be < max = 503316480
# How to Fix
A simple work-around for this issue is checking whether eden committed size is more than its max size. If so, set a minimum committed size for survivor, and recompute eden size accordingly.
- duplicates
-
JDK-8305192 serial GC fails "assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end)) failed: invalid space boundaries"
-
- Closed
-