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 8846509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:00:12+00:00 2026-06-14T12:00:12+00:00

Possible Duplicate: Python: Is it possible to have an actual memory leak in Python

  • 0

Possible Duplicate:
Python: Is it possible to have an actual memory leak in Python because of your code?

Since the python garbage collector handles detection of circular references (object A referencing Object B and Object B referencing Object A), I was wondering what could cause a memory leak in python code? Can you provide specific examples of code that would create an inaccessible region of memory that the garbage collector could not handle or is such a thing impossible?

Any examples appreciated !

  • 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-06-14T12:00:14+00:00Added an answer on June 14, 2026 at 12:00 pm

    You can use the gc — Garbage Collector interface module,

    gc.garbage:

    A list of objects which the collector found to be
    unreachable
    but could not be freed (uncollectable objects). By
    default, this list contains only objects with __del__() methods. [1]
    Objects that have __del__() methods and are part of a reference cycle
    cause the entire reference cycle to be uncollectable, including
    objects not necessarily in the cycle but reachable only from it.
    Python doesn’t collect such cycles automatically because, in general,
    it isn’t possible for Python to guess a safe order in which to run the
    __del__() methods. If you know a safe order, you can force the issue by examining the garbage list, and explicitly breaking cycles due to
    your objects within the list. Note that these objects are kept alive
    even so by virtue of being in the garbage list, so they should be
    removed from garbage too. For example, after breaking cycles, do del
    gc.garbage[:] to empty the list. It’s generally better to avoid the
    issue by not creating cycles containing objects with __del__().
    methods, and garbage can be examined in that case to verify that no
    such cycles are being created.

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

Sidebar

Related Questions

Possible Duplicate: Ternary conditional operator in Python If I have some code like: x
Possible Duplicate: Retrieving python module path Suppose I have code in 3 python files.
Possible Duplicate: Python, compute list difference I have two lists For example: A =
Possible Duplicate: Calling Python from JavaScript I have a test.py and test.js . I
Possible Duplicate: Circular (or cyclic) imports in Python I have class B that imports
Possible Duplicate: how to parse hex or decimal int in Python i have a
Possible Duplicate: True random number generator I have worked with random functions in python,ruby,
Possible Duplicate: Is there any working memory profiler for Python3 I have some script
Possible Duplicate: Python: simple list merging based on intersections I have a multiple list:
Possible Duplicate: Python - Check If Word Is In A String. i have a

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.