getrusage

Discussion in 'Python' started by Stuart D. Gathman, Sep 10, 2003.

  1. When I call resource.getrusage on Linux, I don't get any memory stats:

    Python 2.2.2 (#1, Jan 30 2003, 21:26:22)
    [GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from resource import getrusage,RUSAGE_SELF
    >>> print getrusage(RUSAGE_SELF)

    (0.019531, 0.0078119999999999995, 0, 0, 0, 0, 178, 387, 0, 0, 0, 0, 0, 0, 0, 0)
    >>>


    On AIX, I get the correct numbers.

    What is the goal? I need to find a memory leak in an extension module.
    For starters, I was going to find extension method calls that produce
    unexpected memory use (and I found some on AIX - but our 12 year old AIX
    system is *so* slow). Suggestions are welcome.
    Stuart D. Gathman, Sep 10, 2003
    #1
    1. Advertising

  2. Stuart D. Gathman wrote:
    > When I call resource.getrusage on Linux, I don't get any memory stats:
    >
    > Python 2.2.2 (#1, Jan 30 2003, 21:26:22)
    > [GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
    > Type "help", "copyright", "credits" or "license" for more information.
    >
    >>>>from resource import getrusage,RUSAGE_SELF
    >>>>print getrusage(RUSAGE_SELF)

    >
    > (0.019531, 0.0078119999999999995, 0, 0, 0, 0, 178, 387, 0, 0, 0, 0, 0, 0, 0, 0)
    >
    > On AIX, I get the correct numbers.


    On FreeBSD, you get correct numbers as well. The Linux kernel, however,
    doesn't implement the RUSAGE field, even though it could easily be done
    (I once had the same question as you, and did this research then).

    > What is the goal? I need to find a memory leak in an extension module.


    Try compiling a debug version of Python with the option --with-debug and
    you can debug refcount problems much better.

    -- Gerhard
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Sep 11, 2003
    #2
    1. Advertising

  3. On Wed, 10 Sep 2003 19:49:36 -0400, Gerhard Häring wrote:

    > On FreeBSD, you get correct numbers as well. The Linux kernel, however,
    > doesn't implement the RUSAGE field, even though it could easily be done
    > (I once had the same question as you, and did this research then).
    >
    >> What is the goal? I need to find a memory leak in an extension module.

    >
    > Try compiling a debug version of Python with the option --with-debug and
    > you can debug refcount problems much better.


    The leak turned out to be in the C library wrapped by the extension
    module. I debugged the C library with http://dmalloc.com

    Very nice package.

    --
    Stuart D. Gathman <>
    Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154
    "Confutatis maledictis, flamis acribus addictis" - background song for
    a Microsoft sponsored "Where do you want to go from here?" commercial.
    Stuart D. Gathman, Sep 11, 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. Matthias Oberlaender

    Low resolution of cpu times returned by getrusage

    Matthias Oberlaender, Jul 28, 2003, in forum: Python
    Replies:
    0
    Views:
    334
    Matthias Oberlaender
    Jul 28, 2003
Loading...

Share This Page