s-u / RJDBC

R interface to databases using JDBC
Other
52 stars 47 forks source link

FR: javaGC() for clearing Java heap #66

Closed MichaelChirico closed 5 years ago

MichaelChirico commented 5 years ago

It's not uncommon for me to get eyes to big for my laptop's stomach and try to dbGetQuery some table that's too big for rJava to handle (as configured).

Usually it's the case then that the Java heap gets a bit clogged up and could benefit from a gc(); I recently came upon this Q&A about how to gc() specifically on the Java side; it could be useful to expose a helper function in RJDBC to handle this like

javaGC = function(...) {
  gc(...)
  rJava::J("java.lang.Runtime")$getRuntime()$gc()
  return(invisible())
}

For my own purposes, I'm writing a package that currently has an RJDBC import but no direct rJava import -- could avoid cluttering the DESCRIPTION a bit more if I can importFrom RJDBC instead of rJava.

But I do think that this operation is common enough for RJDBC use cases specifically that exposing this helper here makes sense.

Happy to file a PR if you think it's useful.

s-u commented 5 years ago

This may be actually more useful in rJava since it has nothing to do with RJDBC.

MichaelChirico commented 5 years ago

Filed https://github.com/s-u/rJava/issues/180

s-u commented 5 years ago

Thanks!