Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Configurable Java max memory #68

Merged
merged 2 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rgcam
Title: Tools for importing and working with GCAM results
Version: 1.0.0
Version: 1.1.0
Authors@R: c(person("Robert", "Link", email = "robert.link@pnnl.gov", role = c("aut", "cre", "lyr", "ard")),
person("Pralit", "Patel", email="pralit.patel@pnnl.gov", role="aut"))
Description: This package provides tools for extracting data from GCAM
Expand Down
13 changes: 9 additions & 4 deletions R/querymi.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,20 @@ listScenariosInDB <- function(dbConn)
#' \code{FALSE}, display console output.
#' @param validatedb If \code{TRUE}, check that a simple db query works on the
#' connection; otherwise, don't run the check.
#' @param maxMemory Sets the maximum memory for Java which will be used to run
#' the queries. The default value is \code{"4g"}. Users may need to reduce this
#' value if they are using a 32-bit Java or increase it if they suspect they are
#' running out of memory (by using \code{migabble} to check the log). Note the
#' numeric value can be suffixed with "g" for Gigabyte or "m" for Megabyte.
#' @return A connection to a local BaseX databasse which can be used to run
#' queries.
#' @export
localDBConn <- function(dbPath, dbFile, miclasspath=NULL, migabble=TRUE, validatedb=TRUE) {
localDBConn <- function(dbPath, dbFile, miclasspath=NULL, migabble=TRUE, validatedb=TRUE, maxMemory="4g") {
if(is.null(miclasspath)) {
miclasspath = DEFAULT.MICLASSPATH()
}
db_inst <- structure(
list(miclasspath=miclasspath, dbPath=normalizePath(dbPath), dbFile=dbFile, migabble=migabble),
list(miclasspath=miclasspath, dbPath=normalizePath(dbPath), dbFile=dbFile, migabble=migabble, maxMemory=maxMemory),
class="localDBConn")

if(validatedb) {
Expand Down Expand Up @@ -106,7 +111,7 @@ runQuery.localDBConn <- function(dbConn, query, scenarios=NULL, regions=NULL,
cmd <- c(
"java",
paste("-cp", shQuote(dbConn$miclasspath)),
"-Xmx16g", #TODO: memory limits?
paste0("-Xmx", dbConn$maxMemory),
paste0("-Dorg.basex.DBPATH=", shQuote(dbConn$dbPath)),
paste0("-DModelInterface.SUPPRESS_OUTPUT=", dbConn$migabble),
"org.basex.BaseX",
Expand Down Expand Up @@ -141,7 +146,7 @@ listScenariosInDB.localDBConn <- function(dbConn) {
cmd <- c(
"java",
paste("-cp", shQuote(dbConn$miclasspath)),
"-Xmx4g", #TODO: memory limits?
paste0("-Xmx", dbConn$maxMemory),
paste0("-Dorg.basex.DBPATH=", shQuote(dbConn$dbPath)),
"org.basex.BaseX",
"-smethod=csv",
Expand Down
8 changes: 7 additions & 1 deletion man/localDBConn.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.