Reputation: 61
I have seen several threads on here in relation to receiving the java error: java.lang.OutOfMemoryError: Requested array size exceeds VM limit but I have tried the recommendations and none have worked for me. Below is the script that I have used:
#!/bin/bash
#$ -cwd
#$ -N Sample_S06-9841_A4_primary
#$ -S /bin/bash
module load picard/1.130
java -Xmx12g -XX:MaxPermSize=8192m -XX:+UseCompressedOops -Djava.io.tmpdir=/mnt/work1/users/home2/loldfiel/tmp -jar $picard_dir/picard.jar AddOrReplaceReadGroups INPUT=/mnt/work1/users/roehrlgroup/GCT_2/star_aligner/final_alignment/Sample_S06-9841_A4_primary/Aligned.out.sam OUTPUT=./Sample_S06-9841_A4_primary/S06-9841_A4_primary_rg.bam SORT_ORDER=coordinate RGID=S06-9841_A4_primary RGLB=lib RGPL=Illumina RGPU=none RGSM=Sample_S06-9841_A4_primary
I have tried various different options such as increasing -Xmx argument to 20g and removing the MaxPermSize argument (I've also tried lowering it to 256m). I've run it without using the UseCompressedOops argument.
I've run this script before (without the MaxPermSize and the UsedCompressedOops arguments) and have had no problem at all so I'm not to sure why on this one sample it will not run.
Does anyone have any other ideas as to what the problem could be? Do you think there is an issue with my bam file?
Note: I do receive a file within the output directory but it is empty.
Thank you,
Leslie
Upvotes: 4
Views: 3803
Reputation: 20069
Arrays in java are limited by the fact that the array index is of type int
, and indices must be positive (as well as the array size).
But there may exist limitations within the VM that prevent the use of arrays of the size Integer.MAX_VALUE ((2^31)-1); the exact maximum seems to be implementation specific to the VM. So the VM may throw the exception you get when the requested array length is Integer.MAX_VALUE or very close to it. Note that this cannot be worked around by assigning the VM more memory as its a limitation thats results from how the VM is implemented.
To make matters worse, to my knowledge, there is no constant/method available anywhere in the JDK that actually indicates the actual maximum array size that is supported by the VM; so its hard coding safely for this case.
There may be a way to prevent the program from attempting to allocate arrays of that size by altering its parameters. Your best bet is to seek help directly from the vendor/help forums decicated to your software. Switching to a different VM (version or vendor) may also cure the problem; if the other VM truely supports arrays of maximum size.
Upvotes: 2