Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5953953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:54:01+00:00 2026-05-22T17:54:01+00:00

My python program has a curious performance behavior: The longer it runs, the slower

  • 0

My python program has a curious performance behavior: The longer it runs, the slower it gets. Early on, it cranks out tens of work units per minute. After an hour of so it is taking tens of minutes per work unit. My suspicion is that this is cause by a congested garbage collector.

The catch is that my script is too memory hungry for cProfile to work on large runs. (see: cProfile taking a lot of memory)

We have written our own performance plugin and we can observe most parts of our system and none of them seem to be the problem. The one rock that is still unturned is the GC.

Is there some other way (besides profile or cProfile) to see how much time is going to the GC?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:54:02+00:00Added an answer on May 22, 2026 at 5:54 pm

    In Python, most garbage is collected using reference counting. One would expect this to be quick and painless, and it seems unlikely that this is what you’re after. I assume you’re asking about the collector referred to by the gc module, which is only used for circular references.

    There are a few things that might be of use: http://docs.python.org/library/gc.html

    Although there doesn’t appear to be a direct method to time the garbage collector, you can turn it on and off, enable debugging, look at collection count etc. All of this might be helpful in your quest.

    For example, on my system gc prints out the elapsed time if you turn on the debug flags:

    In [1]: import gc
    
    In [2]: gc.set_debug(gc.DEBUG_STATS)
    
    In [3]: gc.collect()
    gc: collecting generation 2...
    gc: objects in each generation: 159 2655 7538
    gc: done, 10 unreachable, 0 uncollectable, 0.0020s elapsed.
    

    All of this aside, the first thing I would look at is the evolution of the memory usage of your program as it runs. One possibility is that it is simply reaching the limit of available physical RAM and is slowing down due to excessive page faults, rather than due to anything to do with the garbage collector.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My python program has many function which all seem to work fine when run
Okay. I have completed my first python program.It has around 1000 lines of code.
I'd like to have a python program alert me when it has completed its
I have a python program, which runs on the CPython implementation, and inside it
I am calling a python script from PHP. The python program has to return
My program has been written on python 3.1 (it was the biggest mistake I've
My client has two offices in Germany and USA and a python program should
I'm having troubles getting this to work. Basically I have a python program that
I have a Python program (PP) that loads another Program(AP) via COM, gets its
I have a Python program that runs a series of experiments, with no data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.