nealrichardson commented on a change in pull request #8533:
URL: https://github.com/apache/arrow/pull/8533#discussion_r514535632
##########
File path: r/tests/testthat/test-arrow.R
##########
@@ -60,3 +60,17 @@ test_that("arrow gracefully fails to load objects from other
sessions (ARROW-100
test_that("check for an ArrowObject in functions use std::shared_ptr", {
expect_error(Array__length(1), "Invalid R object")
})
+
+test_that("MemoryPool calls gc() to free memory when allocation fails
(ARROW-10080)", {
+ env <- new.env()
+ trace(gc, print = FALSE, tracer = function() {
+ env$gc_was_called <- TRUE
+ })
+ expect_error(
+ BufferOutputStream$create(2 ** 60),
+ "Out of memory"
+ )
+ expect_true(env$gc_was_called)
+
+ untrace(gc)
Review comment:
```suggestion
on.exit(untrace(gc))
# We expect this should fail because we don't have this much memory,
# but it should gc() and retry (and fail again)
expect_error(BufferOutputStream$create(2 ** 60))
expect_true(env$gc_was_called)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]