Determine memeory usage of Arrays or other objects

J

john maclean

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
 
R

Robert Klemme

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.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,082
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top