Home > Net >  Is this not how memory allocation works in R
Is this not how memory allocation works in R

Time:01-28

I was testing how the RAM/memory allocation works in R. For example, the object size of Iris (150 rows) is 8.9 kb (I am assuming for 1 row it is 8.9/150). But for 1 row, the object size is 2.06 kb (How is it?) . Can anyone explain?

So is this not how allocation works. Total Memory = No of rows * memory / per each row

> object_size(iris)
8.9 kB
> object_size(head(iris,n = 1))
2.06 kB
> 2.06 * 150
[1] 309 kb

CodePudding user response:

Not quite, the dataframe itself takes quite a bit of memory, just the structure. Try this

> object.size(head(iris,n = 1))
1896 bytes
> object.size(head(iris,n = 2))
1928 bytes
> object.size(head(iris,n = 3))
2000 bytes

for a feeling.

  •  Tags:  
  • Related