Hi,

I have below lines of code to understand how R manages memory.

> library(pryr)

*Warning message:*

*package ‘pryr’ was built under R version 3.4.3 *

> mem_change(x <- 1:1e6)

4.01 MB

> mem_change(y <- x)

976 B

> mem_change(x[100] < NA)

976 B

> mem_change(rm(x))

864 B

> mem_change(rm(y))

-4 MB

>

I do understand why there is only 976 B positive change in the 3rd line.
This is because now y and x both points to the same block of memory that
holds 1:1e6.

But I dont understand below

> mem_change(rm(x))

864 B
Why memory consumption increased here while deleting an object, although by
a small amount?

Any detailed explanation will be appreciated. Thanks,

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to