Commit 827798ea authored by Romulo Pereira Goncalves's avatar Romulo Pereira Goncalves
Browse files

Models needs to be initialized since now we use models_list. Remove more...

Models needs to be initialized since now we use models_list. Remove more variables and call garbage collector.
parent ec1e8e93
......@@ -119,6 +119,7 @@ sample_nb <- function(raster,
points_list[[k]] <- res[["k" = k]][["points"]]
models_list[[k]] <- res[["k" = k]][["models"]]
oobe[, k] <- res[["k" = k]][["oobe"]][, 1]
remove(res)
}
} else {
for (k in 1:nb_mean) {
......@@ -143,6 +144,7 @@ sample_nb <- function(raster,
points_list[[k]] <- res$points
models_list[[k]] <- res$models
oobe[, k] <- res$oobe[, 1]
remove(res)
setTxtProgressBar(pb, k)
}
}
......@@ -151,12 +153,17 @@ sample_nb <- function(raster,
which_models_null <- vapply(models_list, is.not.null <- function(x){!is.null(x)}, FALSE)
if (length(models_list) == 0 |
length(which_models_null[which_models_null == FALSE]) == length(models_list)) {
remove(points_list)
remove(models_list)
remove(ooe)
stop("No Models - would you be so kind to increase init.samples, please")
}
if (length(which_models_null[which_models_null == FALSE]) > 0) {
models <- models_list[which_models_null]
remove(models_list)
} else {
models <- models_list
}
remove(models_list)
for (jj in 1:nrow(reference)) {
ref <- jj
......@@ -218,6 +225,8 @@ sample_nb <- function(raster,
if (save_runs == TRUE) {
mod_all <- models
} else {
mod_all = list()
}
models <- models[ch]
print(paste("n_models =", length(models)))
......@@ -284,8 +293,9 @@ sample_nb <- function(raster,
remove(switch)
remove(layer)
remove(mod_all)
remove(diff)
remove(dif)
remove(seed2)
gc()
out <- list(index = index, acc = acc, obj = obj)
return(out)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment