Fix IndexOutOfBoundsException raised when numHeapArenas and numDirectArenas differ

- Fixes #1227