Memory management in R
Memory management primarily deals with the administration of available memory and the prediction of additional memory required for smoother and faster execution of functions. The current section will cover the concept of memory allocation, which deals with storage of an object in the R environment.
During memory allocation R allocates memory differently to different objects in its environment. Memory allocation can be determined using the object_size
function from the pryr
package. The pryr
package can be installed from the CRAN repository using install.packages("pryr")
. The package is available for R (≥ 3.1.0). The object_size
function in pryr
is similar to the object.size
function in the base package. However, it is more accurate as it takes into account the:
- Environment size associated with the current object
- Shared elements within a given object under consideration.
The following are examples of using the object_size
function in R to evaluate...