r-lib / lobstr

Understanding complex R objects with tools similar to str()
https://lobstr.r-lib.org/
Other
303 stars 27 forks source link

Differences between lobstr::mem_used() & memuse::Sys.procmem() #73

Closed mitch-tanney-coterie closed 1 month ago

mitch-tanney-coterie commented 3 months ago

I currently see differences in reported memory consumption between the following commands.

print(lobstr::mem_used())
print(memuse::Sys.procmem()$size)

The result from the memuse::Sys.procmem()$size command matches or is very close to the values I see in the RStudio Environment pane.

Therefore, what exactly is lobstr::mem_used() describing? I apologize in advance if I'm missing something obvious in the documentation, but I'm curious to know the differences between these commands.

hadley commented 1 month ago

Basically, mem_used() reports the memory that R tracks from inside the process, and I suspect what memuse and RStudio track are the memory usage of the entire process (as reported by the operating system).