Determine memeory usage of Arrays or other objects

k = [nil] *50000

is there a way to get some idea of how much memory k will use, or even
how much mem it may use as k.size changes?

ruby -e 'p Array.methods.sort' does not show anything obvious.

···

--
John Maclean
07739 171 531
MSc (DIC)

Timezone: GMT

And there isn't an obvious solution. You can check the archives - this discussion comes up from time to time. Basically it is unclear what "memory taken up by an object" means. The simplest answer is the amount of memory that is needed to store the object itself. But what about references? Do you count objects in that are referenced by the Array? If so, how many levels do you track? Etc. You even might not find your memory problem by only looking at Array memory (assuming you have a memory issue).

Kind regards

  robert

···

On 25.02.2009 18:16, john maclean wrote:

k = [nil] *50000

is there a way to get some idea of how much memory k will use, or even
how much mem it may use as k.size changes?

ruby -e 'p Array.methods.sort' does not show anything obvious.