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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:09:21+00:00 2026-06-15T12:09:21+00:00

I am trying to figure out when exactly a python object is a candidate

  • 0

I am trying to figure out when exactly a python object is a candidate for garbage collection. I have read through a few documents/posts and have been unable to find a definite answer.

Take for example the following line. This is the last reference to foo. When is the object pointed to by foo available for garbage collection?

ret = func(['xyz: ' + foo.name])

Breaking it down to the (possible) individual steps:

  1. temporary reference to name is created.
  2. ‘xyz: ‘ is concatenated with name and value is returned.
  3. list is created with the new string.
  4. function is called with new array.
  5. function returns.
  6. result is assigned to ret.
  7. next instruction…

Between which two steps is the object first eligible to be collected? When is the reference count to the object decremented?

If the list of steps is incomplete/incorrect please let me know as well. I only attempted to enumerate them to give a common starting place for the potential answers to reference.

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

    The variable will be eligible for garbage collection as soon as all references to it go out of scope or are manually deleted (del x).

    In your example, foo must exist before this line (otherwise it’s a NameError), and therefore will never be garbage collected in your example block of code, as the reference will still exist after this. Even if one were to call del foo after this, we would have to presume there were no references to the object anywhere else for it to be garbage collected.

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

Sidebar

Related Questions

I'm new to python and have been trying to figure this out all day.
I am trying to figure out how exactly Wordpress works around blog posts so
I have following html and I am trying to figure out how exactly I
I am trying to figure out exactly what these new fangled data stores such
I am trying to figure out exactly how to implement a callback function which
I'm trying to figure out what exactly Dependency Properties are, but when I look
I've been trying to figure out what exactly is happening here. I'm just trying
Just out of curiosity, I'm trying to figure out which exactly is the right
trying to figure out why this is happening - I have an input text
I am trying to figure out how exactly does treesort from here work (I

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.