Determine Memory Usage of Data Objects in R
In this article, we are going to discuss how to find the memory used by the Data Objects in R Language. In R, after the creation of the object, It will allocate some space to the particular object. The object in memory is stored in bytes. Numeric type can allocate 56 bytes and character type can allocate 112 bytes.
Method 1: Using memory.profile()
memory.profile(): It will show the Lists the usage of the cons cells by SEXPREC type. If you want to know all the memory profiles in R, You can get it using memory.profile() function.
Method 2: Using object.size()
If you want to get individual object size then we can get it by using object.size() function
Where, data_object is the R object.
Example 1: R program to get the bytes sizes of numeric and character objects.
56 bytes 112 bytes
Example 2: Get the list of datatype sizes using sapply().
If we want to get the all datatype sizes at a time, we can apply sapply() function along with object.size() function with ls() function. R program to create 5 variable sin workspace and determine the memory in bytes
a average.z b c climbing climbing.z
56 96 112 56 96 96
d drink drink.z e error_values x
112 96 96 56 112 112