Skip to content

Commit

Permalink
Multicore memory fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tylermorganwall committed Jul 4, 2018
1 parent a9c4f5e commit 9e3b11c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rayshader
Type: Package
Title: Raytraces Elevation Matrices to Produce Global Illumination Relief Maps
Version: 0.3.1
Version: 0.3.2
Date: 2018-06-30
Author: Tyler Morgan-Wall
Maintainer: Tyler Morgan-Wall <[email protected]>
Expand Down
5 changes: 3 additions & 2 deletions R/ray_shade.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ ray_shade = function(heightmap, anglebreaks=seq(40,50,1), sunangle=315, maxsearc
}
cl = parallel::makeCluster(numbercores, ...)
doParallel::registerDoParallel(cl, cores = numbercores)
shadowmatrix = tryCatch({
foreach::foreach(i=1:nrow(heightmap), .combine="rbind", .packages = c("rayshader")) %dopar% {
shadowmatrixlist = tryCatch({
foreach::foreach(i=1:nrow(heightmap), .packages = c("rayshader")) %dopar% {
rayshade_multicore(sunangle = sunangle_rad, anglebreaks = anglebreaks_rad,
heightmap = heightmap, zscale = zscale,
maxsearch = maxsearch, row = i-1, cache_mask = cache_mask[i,])
Expand All @@ -83,6 +83,7 @@ ray_shade = function(heightmap, anglebreaks=seq(40,50,1), sunangle=315, maxsearc
parallel::stopCluster(cl)
}, error = function (e) {})
})
shadowmatrix = do.call(rbind,shadowmatrixlist)
shadowmatrix[shadowmatrix<0] = 0
if(remove_edges) {
shadowmatrix = shadowmatrix[c(-1,-nrow(shadowmatrix)),c(-1,-ncol(shadowmatrix))]
Expand Down

0 comments on commit 9e3b11c

Please sign in to comment.