Determine memeory usage of Arrays or other objects

Discussion in 'Ruby' started by john maclean, Feb 25, 2009.

  1. john maclean

    john maclean Guest

    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
     
    john maclean, Feb 25, 2009
    #1
    1. Advertising

  2. 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.


    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
     
    Robert Klemme, Feb 25, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ravi

    System Memeory

    Ravi, Mar 27, 2006, in forum: Java
    Replies:
    11
    Views:
    663
    Chris Uppal
    Mar 30, 2006
  2. subrat

    memeory related

    subrat, Dec 11, 2006, in forum: C++
    Replies:
    10
    Views:
    572
    Kai-Uwe Bux
    Dec 11, 2006
  3. Pallav singh
    Replies:
    2
    Views:
    344
    Erik Wikström
    Dec 24, 2007
  4. globalrev

    Fill memeory with endless loop?

    globalrev, May 13, 2008, in forum: Python
    Replies:
    6
    Views:
    279
    Bruno Desthuilliers
    May 14, 2008
  5. Kasper Middelboe Petersen

    Removing access to parts of memeory

    Kasper Middelboe Petersen, Oct 1, 2010, in forum: C++
    Replies:
    9
    Views:
    321
    Victor Bazarov
    Oct 5, 2010
Loading...

Share This Page