Skip to content

Instantly share code, notes, and snippets.

@multimeric
Created March 14, 2024 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save multimeric/668743923354ab7820a92a36d6ab1f46 to your computer and use it in GitHub Desktop.
Save multimeric/668743923354ab7820a92a36d6ab1f46 to your computer and use it in GitHub Desktop.
Demonstration of odd memory usage in R whereby the resident set size (RSS) doesn't change despite allocating more memory and later clearing it
RSQLite::SQLite() |>
  DBI::dbConnect(":memory:") |>
  RSQLite::dbWriteTable("foo", data.frame(
  a = numeric(1E8)
))
invisible(gc())
ps::ps_memory_info()
##        rss        vms     shared       text        lib       data      dirty 
## 1076400128 1299771392   10223616       4096          0 1074139136          0
y <- integer(1E8)
ps::ps_memory_info()
##        rss        vms     shared       text        lib       data      dirty 
## 1076400128 1299771392   10223616       4096          0 1074139136          0
rm(y)
invisible(gc())
ps::ps_memory_info()
##        rss        vms     shared       text        lib       data      dirty 
## 1076400128 1299771392   10223616       4096          0 1074139136          0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment