-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pipe can prevent GC of object if S3 method is used #229
Comments
Remove all these symbols from ❯ ls(environment(e1), all.names = TRUE)
[1] "..." ".Class" ".Generic" ".GenericCallEnv"
[5] ".GenericDefEnv" ".Group" ".Method" Actually, scratch that, it won't.... |
Interesting -- if I add this to the inside of rm(., envir = .GenericCallEnv) Or you can run this outside of the function, after rm(., envir = environment(e1)$.GenericCallEnv) But when I poke at it, I don't see how Run this after the code above (except for the rls(environment(e1)$.GenericCallEnv$., all.names = TRUE)
#> [[1]]
#> character(0)
#>
#> [[2]]
#> [1] ".Random.seed" "e1" "f" "f.default" "finalized"
rm(., envir = environment(e1)$.GenericCallEnv)
gc()
#> finalized
expect_true(finalized) |
|
I concur with @gaborcsardi:
|
Oh, duh, that makes sense. I just didn't have any identifying information in |
I think this is a duplicate of #146. It's the conjunction of two factors:
This issue will disappear if you use the base pipe in the next version of R because it simply transforms the parse tree to the nested form. If you add this to your reprex, to use the same transformation, the issue goes away: # Needs dev version
`%>%` <- magrittr::pipe_nested I think I'd rather avoid making ad hoc cleanups for the specific case of S3 dispatch within the pipe mask because it might cause unintended effects and we're about to release magrittr. |
Yes, it's the same as #146. I have a workaround in place for one of my packages, which cleans up this reference, because this issue was causing OOM to my users. |
The pipe can prevent GC of an object that's passed into it. It happens when:
It seems that using the pipe causes there to be a reference to the object being piped
Here's an example where the use of
%>%
results in the object not being GC'd. However, if the function is called without the pipe, the object does get GC'd.The text was updated successfully, but these errors were encountered: