Last active
June 24, 2016 07:11
-
-
Save szilard/14d4e0b73ca17a3ac42d5c7442c5122d to your computer and use it in GitHub Desktop.
R 1TB bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## allocate <1TB first, stuff works | |
> x <- 1:1.2e11 | |
> gc() | |
used (Mb) gc trigger (Mb) max used (Mb) | |
Ncells 214403 11.5 4.60000e+05 24.6 350000 18.7 | |
Vcells 120000397293 915530.4 1.72801e+11 1318366.9 120000398080 915530.4 | |
> system("echo 1") | |
1 | |
## allocate more, so >1TB allocated (total RAM ~2TB) | |
> y <- 1:0.2e11 | |
> gc() | |
used (Mb) gc trigger (Mb) max used (Mb) | |
Ncells 214670 11.5 460000 24.6 350000 18.7 | |
Vcells 140000397805 1068118.3 207361249221 1582040.8 140000400143 1068118.3 | |
## this breaks: | |
> system("echo 1") | |
Warning message: | |
In system("echo 1") : system call failed: Cannot allocate memory | |
> sessionInfo() | |
Error in system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE) : | |
cannot popen '/usr/bin/which 'uname' 2>/dev/null', probable reason 'Cannot allocate memory' | |
> library() | |
Warning messages: | |
1: In library() : library ‘/usr/lib/R/site-library’ contains no packages | |
2: In file.show(outFile, delete.file = TRUE, title = gettext("R packages available")) : | |
system call failed: Cannot allocate memory | |
## allocation in general still works: | |
> system.time(z <- 1:1e8) | |
user system elapsed | |
0.053 0.088 0.140 | |
## deallocate some (<1TB allocated now) | |
> y <- NULL | |
> gc() | |
used (Mb) gc trigger (Mb) max used (Mb) | |
Ncells 224057 12.0 460000 24.6 404441 21.6 | |
Vcells 120000414088 915530.6 207361249221 1582040.8 140000676821 1068120.4 | |
## stuff works again | |
> system("echo 1") | |
1 | |
> sessionInfo() | |
R version 3.3.0 (2016-05-03) | |
Platform: x86_64-pc-linux-gnu (64-bit) | |
Running under: Ubuntu 14.04.4 LTS | |
[...] | |
> library() | |
Packages in library ‘/usr/local/lib/R/site-library’: | |
[...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment