RE: Memory allocation

Discussion in 'Python' started by Batista, Facundo, Sep 22, 2003.

  1. #- Knowing how much memory the object consumes will not help you with
    #- that, at least in general. The object could easily be changed in a
    #- dozen ways yet still consume the same amount of memory.

    No, sorry. Knowing how much memory consumes, gives me if it's a viable
    solution.


    #- Can't the object just track changes to itself? This is a fairly
    #- common solution to the general problem you describe. Resorting to
    #- things like checking memory consumption is not likely the best way
    #- to approach this.

    Thought this. But gives me an API not separated from my main code (I have to
    subclass each class from another one).


    #- > but it still remains a general question: the other
    #- > day I wanted to know "how much more expensive in memory is
    #- a list than a
    #- > tuple for a given content".
    #-
    #- I believe the answer was given, but in case it wasn't: they take
    #- effectively the same amount of memory, as each is basically a series
    #- of pointers to other objects.

    That's OK.

    But, there is a way to know the memory consumption?
    Batista, Facundo, Sep 22, 2003
    #1
    1. Advertising

  2. I don't know about memory usage, but can you use
    >>> hash(pickledItem)


    Hashing is a very common way to confirm accuracy in file downloads, for
    instance.

    - Simon.

    "Batista, Facundo" <> wrote in
    news::

    > #- Can't the object just track changes to itself? This is a fairly
    > #- common solution to the general problem you describe. Resorting to
    > #- things like checking memory consumption is not likely the best way
    > #- to approach this.
    >
    > Thought this. But gives me an API not separated from my main code (I
    > have to subclass each class from another one).
    Simon Bayling, Sep 23, 2003
    #2
    1. Advertising

  3. Batista, Facundo

    Peter Hansen Guest

    "Batista, Facundo" wrote:
    >
    > #- Knowing how much memory the object consumes will not help you with
    > #- that, at least in general. The object could easily be changed in a
    > #- dozen ways yet still consume the same amount of memory.
    >
    > No, sorry. Knowing how much memory consumes, gives me if it's a viable
    > solution.


    Hmm... you mean the memory consumption had nothing to do with detecting
    the change? You just want to know if holding the pickled object in
    memory is viable? If that's what you mean, I must be missing something...
    a pickle is just a serialized (i.e. flat) representation of the data
    as a series of bytes, right? In other words, a string? So call len()
    on it... (as I said, that sounds too easy so I must be missing something).

    > But, there is a way to know the memory consumption?


    Not really, although I suspect there have been past postings to the
    newsgroup (maybe check the archives) in which people have experimented
    with partial solutions to this problem. It's not generally something
    that seems to come up very often.

    -Peter
    Peter Hansen, Sep 23, 2003
    #3
    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. s.subbarayan

    Dynamic memory allocation and memory leak...

    s.subbarayan, Mar 18, 2005, in forum: C Programming
    Replies:
    10
    Views:
    681
    Eric Sosman
    Mar 22, 2005
  2. Rodrigo Dominguez

    memory allocation and freeing memory

    Rodrigo Dominguez, Jun 13, 2005, in forum: C Programming
    Replies:
    11
    Views:
    586
    Jean-Claude Arbaut
    Jun 15, 2005
  3. Ken
    Replies:
    24
    Views:
    3,839
    Ben Bacarisse
    Nov 30, 2006
  4. chris
    Replies:
    6
    Views:
    974
    chris
    Oct 28, 2005
  5. Bjarke Hammersholt Roune
    Replies:
    14
    Views:
    1,170
    Bjarke Hammersholt Roune
    Mar 6, 2011
Loading...

Share This Page