java - I'm trying to load 500Mb file (Files.readAllBytes) and I need more than 2 Gb Heap size. Why? -



java - I'm trying to load 500Mb file (Files.readAllBytes) and I need more than 2 Gb Heap size. Why? -

i'm trying load 500mb file in memory (files.readallbytes) , need more 2 gb heap size.

with default settings have outofmemoryerror: java heap space. when set -xmx1000m doesn't work. works if set @ to the lowest degree -xmx2300m -xmx2300m. why java need such overhead?

two possible answers come mind,

the library phone call using copying bytes between buffers more once, multiplying amount of memory need. the heap separated logical parts (generations). when allocating 'large' object not fit generation object tenured early. if there not space in old gen, object allocation fail. combine 1 above, , little heap , 1 can see how java nail trouble.

the simplest solution both problems memory map file instead, allocate memory off heap , efficient/fast @ reading file in reduces number of os context switches , byte buffer copies involved in reading file.

java

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -