To get the shared memory used by R, you can try mem_used() from the pryr package. Unlike memory.size , this is OS independent because the R gc() function is used underneath. Try looking at the body of the function, as well as at pryr:::node_size and pryr:::show_bytes
pryr::mem_used()
Help file ?pryr::mem_used describes
R interrupts the memory usage in Vcell (memory used by vectors) and Ncells (memory used by everyone else). However, neither these differences nor the columns "gc trigger" and "max used" are usually important. Usually we are most interested in the first column: shared memory usage. This function wraps itself around gc () to return the total amount of memory (in megabytes) currently used by R.
You can also use pryr::mem_change to track the size of memory used by the R code. Try the example on the documentation page.
Numbers such as 28L and 56L , used to indicate the size of a node with pryr:::node_size , come from the help file ?gc , which describes
gc returns a matrix with the lines "Ncells" (cons cells), usually 28 bytes each of 32-bit systems and 56 bytes in 64-bit systems and "Vcells", (vector cells, 8 bytes each),
After deleting a large object, run gc() in free memory
source share