SantanderMetGroup / loadeR

A climate4R package for data access
https://github.com/SantanderMetGroup/climate4R
GNU General Public License v3.0
13 stars 13 forks source link

java heap space error #91

Open Angie891 opened 1 year ago

Angie891 commented 1 year ago

Hello,

while using the loadGridData function, I get following error:

[2023-03-30 13:53:33] Retrieving data subset ... Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.lang.OutOfMemoryError: Java heap space Calls: loadGridData ... array -> -> .jrcall -> .jcall -> .jcheck

I tried same code on two different machines, windows and linux, with different files.

On linux, I tried to read nc file of size 4.8GB (25 years of daily data) on a machine that has java heap size assigned to 27.8GB, and it gave me above error.

Then I tried same code with smaller files (~700MB) on a windows machine that has java heap size assigned to 13GB, and it can read only one file. If I try to read two files in a row, I get same error above. (if I use gc() between the files, it reads files with no issues)

It seems that loadGridData requires java heap space size rougly 10 times higher than the file size it is reading, which makes it quite hard to use with bigger files.

Given I am doing quantile mapping, the results will differ whether I do it on whole period or just on part of the period, so I am wondering is there any solution for this~ Thanks in advance!

durutti commented 1 year ago

I had the same issue with files about 7gb the following command before calling loadeR solved the issue for me options(java.parameters = "-Xmx10g")

Angie891 commented 1 year ago

My memory was set to 27.8GB. I finally solved the issue by talking to system admin and adjusting java heap size to 100GB on the linux system - options(java.parameters = "-Xmx60g") still gave me same error, 80Gb or 100GB works!! I don't understand why it needs SO much memory, but for some reason it does :/

QuocPhamBao commented 10 months ago

I got the same issue, anybody had solution for this?