-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Labels
Description
Error description
Object size increases when importing multiple modules. This is really strange, because nothing happens to the object environment. In this example the size increases from 435kB to 26MB (!) just when loading 2nd module. Looks like all imported objects share the same resources, because finally all of them have the same accumulated size.
m1.R
box::use(dplyr[mutate])
#' @export
foo <- function(x){
x |> mutate(m1 = 1)
}
dummy <- 2
m2.R
box::use(ggplot2[ggplot, aes, geom_point])
#' @export
bar <- function(x){
ggplot(x, aes(Sepal.Width, Petal.length)) + geom_point()
}
m3.R
box::use(tidyr[drop_na])
#' @export
baz <- function(x){
drop_na(x)
}
some_var <- "hi"
console output
> box::use(. / m1[foo])
>
> pryr::object_size(foo)
435.83 kB
>
> box::use(. / m2[bar])
>
> pryr::object_size(foo) # the object size increases
25.84 MB
> pryr::object_size(bar)
25.84 MB
>
> ls(environment(foo)) # environments look as expected
[1] "dummy" "foo"
> ls(environment(bar))
[1] "bar"
>
> box::use(. / m3[baz])
>
> pryr::object_size(foo) # all objects have the same size
25.96 MB
> pryr::object_size(bar)
25.96 MB
> pryr::object_size(baz)
25.96 MB
R version
> R.version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 4
minor 1.1
year 2021
month 08
day 10
svn rev 80725
language R
version.string R version 4.1.1 (2021-08-10)
nickname Kick Things
‘box’ version
1.2.0