Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I know how much memory each loaded R package is taking up?

Tags:

package

r

Whether I want to load a package that contains a function that I want versus writing my own function depends largely on the size of the package. How I can get the size of the package (without looking through my directories) with code? Also, is there code that can tell me how much memory each of my loaded/attached packages are taking up in my workspace?

like image 400
vivian Avatar asked Mar 07 '23 07:03

vivian


1 Answers

Loading packages does not take much memory. You can use mem_used() function from package pryr to estimate the memory growth with each package being loaded:

library(pryr)

mem_used()
# 74.1 MB

library(dplyr)
mem_used()
# 77 MB

library(data.table)
mem_used()
#78.2 MB
like image 117
Katia Avatar answered Apr 07 '23 08:04

Katia