Unverified Commit eda0d3ca authored by david-cortes's avatar david-cortes Committed by GitHub
Browse files

[R-package] Fix R memory leaks (fixes #4282, fixes #3462) (#4597)

* fix R memory leaks

* attempt at solving linter complaints

* fix compilation on windows

* move R_API_BEGIN to correct place

* make sure exception objects reach out of scope

* better way to solve rchk complaints

* remove goto statement
parent 2c8bb45b
This diff is collapsed.
......@@ -1779,7 +1779,6 @@ test_that("lgb.train() fit on linearly-relatead data improves when using linear
test_that("lgb.train() w/ linear learner fails already-constructed dataset with linear=false", {
testthat::skip("Skipping this test because it causes issues for valgrind")
set.seed(708L)
params <- list(
objective = "regression"
......
......@@ -693,7 +693,6 @@ test_that("Saving a model with different feature importance types works", {
})
test_that("Saving a model with unknown importance type fails", {
testthat::skip("Skipping this test because it causes issues for valgrind")
set.seed(708L)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
......
......@@ -18,8 +18,8 @@
#ifdef LGB_R_BUILD
#define R_NO_REMAP
#define R_USE_C99_IN_CXX
#include <R_ext/Error.h>
#include <R_ext/Print.h>
extern "C" void R_FlushConsole(void);
#endif
namespace LightGBM {
......@@ -124,7 +124,8 @@ class Log {
fprintf(stderr, "[LightGBM] [Fatal] %s\n", str_buf);
fflush(stderr);
#else
Rf_error("[LightGBM] [Fatal] %s\n", str_buf);
REprintf("[LightGBM] [Fatal] %s\n", str_buf);
R_FlushConsole();
#endif
throw std::runtime_error(std::string(str_buf));
}
......@@ -154,6 +155,7 @@ class Log {
Rprintf("[LightGBM] [%s] ", level_str);
Rvprintf(format, val);
Rprintf("\n");
R_FlushConsole();
#endif
}
}
......
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