Skip to content

Instantly share code, notes, and snippets.

@joshuaulrich
Created January 28, 2018 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuaulrich/9dd96009b2cfb6f6b1dfce07461bfb97 to your computer and use it in GitHub Desktop.
Save joshuaulrich/9dd96009b2cfb6f6b1dfce07461bfb97 to your computer and use it in GitHub Desktop.
Force an R garbage collection from C
void do_gc(SEXP env) {
SEXP s, t;
PROTECT(s = t = allocList(1));
SET_TYPEOF(s, LANGSXP);
SETCAR(t, install("gc")); t = CDR(t);
PrintValue(eval(s, env));
UNPROTECT(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment