I'm on a 64 bit OS on a Mac with 8GB of RAM. I need to allocate 2.9GB to some arrays of bytes in a program written in Java (I simply declare them). Since by default you can't use more than 1GB of heap space for running a java project, you need to specify in the VM options if your program needs more. I am on IntelliJ Idea, so I do this by going on Help -> Edit Custom VM Options and then changing the -xmx field. But no matter how many MBs I allocate, the program can't run due to this exception: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space, as if I didn't change anything in the VM options. The PC has enough free RAM to contain arrays of 2.9GB when running the program.
Asked
Active
Viewed 631 times
0
Mark Smith
- 103
- 3
-
1What did you set the heap size to? – Stephen C Aug 03 '19 at 15:39
-
1Are you sure it isn't consuming more than 2.9GB? And what are you passing as the `-xmx` argument? – Carcigenicate Aug 03 '19 at 15:41
-
1Are you 100% sure about not allocate more than 2,9GB, one tip is know what type of data did you use, because for example int type allocates 4 bits – deon cagadoes Aug 03 '19 at 15:46
1 Answers
1
Help -> Edit Custom VM Options is set for IDEA itself but not your program. Set -Xmx in Run -> Edit Configurations.. -> your application -> VM options instead.
djzhu
- 787
- 8
- 11