As for Ruby version 2.2 to know the size of memory occupied by the object?

Decided to ask how much memory that eats up the array, but never googled the answer. Among the answers was not relevant to version 2.2.
July 2nd 19 at 13:20
1 answer
July 2nd 19 at 13:22
You need to connect the standard library ObjectSpace
Module ObjectSpace has the method memsize_of(obj).

require 'objspace'
hash = {a: 1, b: 2}
# => 240
Yes. It turns out that the whole point is that without require 'objspace' memsize_of method is not defined, because of what I decided that in version 2.2, this method of determining size is not working. - alfonso56 commented on July 2nd 19 at 13:25

Find more questions by tags Ruby