memory - Error: cannot allocate vector of size X Mb in R -
i have question regarding memory usage in r. running rcode on our entire database in r in loop. however, code stops @ point saying cannot allocate vector of size 325.7 mb. when looking @ task manager saw using 28gb of ram on our server.
i familiar gc()
function in r not seems work. e.g. code stopped working on 15th iteration, saying cannot allocate vector. however, if run 15th iteration (and nothing else) there no problem @ all. moreover, each new iteration delete dt far largest object in environment.
code sample:
dt <- data.table() items <- as.character(seq(1:10)) (i in items){ dt <- sample(x = 5000,replace = t) write.csv(dt,paste0(i,".csv")) gc() rm(dt) }
i have feeling gc
function not work in loop. correct or there other possible issues, i.e. there reasons why memory full after few iterations?
Comments
Post a Comment