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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:09:30+00:00 2026-06-04T08:09:30+00:00

If I have a garbage collector that tracks every object allocated and deallocates them

  • 0

If I have a garbage collector that tracks every object allocated and deallocates them as soon as they no longer have usable references to them can you still have a memory leak?

Considering a memory leak is allocations without any reference isn’t that impossible or am I missing something?

Edit: So what I’m counting as a memory leak is allocations which you no longer have any reference to in the code. Large numbers of accumulating allocations which you still have references to aren’t the leaks I’m considering here.

I’m also only talking about normal state of the art G.C., It’s been a while but I know cases like cyclical references don’t trip them up. I don’t need a specific answer for any language, this is just coming from a conversation I was having with a friend. We were talking about Actionscript and Java but I don’t care for answers specific to those.

Edit2: From the sounds of it, there doesn’t seem to be any reason code can completely lose the ability to reference an allocation and not have a GC be able to pick it up, but I’m still waiting for more to weigh in.

  • 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-04T08:09:32+00:00Added an answer on June 4, 2026 at 8:09 am

    If your question is really this:

    Considering a memory leak is allocations without any reference isn’t
    that impossible or am I missing something?

    Then the answer is “yes, that’s impossible” because a properly implemented garbage collector will reclaim all allocations that don’t have active references.

    However, you can definitely have a “memory leak” in (for example) Java. My definition of a “memory leak” is an allocation that still has an active reference (so that it won’t be reclaimed by the garbage collector) but the programmer doesn’t know that the object isn’t reclaimable (ie: for the programmer, this object is dead and should be reclaimed). A simple example is something like this:

    ObjectA -> ObjectB

    In this example, ObjectA is an object in active use in the code. However, ObjectA contains a reference to ObjectB that is effectively dead (ie: ObjectB has been allocated and used and is now, from the programmer’s perspective, dead) but the programmer forgot to set the reference in ObjectA to null. In this case, ObjectB has been “leaked”.

    Doesn’t sound like a big problem, but there are situations where these leaks are cumulative. Let’s imagine that ObjectA and ObjectB are actually instances of the same class. And this problem that the programmer forgot to set the reference to null happens every time such an instance is used. Eventually you end up with something like this:

    ObjectA -> ObjectB -> ObjectC -> ObjectD -> ObjectE -> ObjectF -> ObjectG -> ObjectH -> etc…

    Now ObjectB through ObjectH are all leaked. And problems like this will (eventually) cause your program to crash. Even with a properly implemented garbage collector.

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

Sidebar

Related Questions

It seams that Dalvik's garbage collector doesn't respect SoftReferences and removes them as soon
I have seen many Android answers that suggest calling the garbage collector in some
I have heard it many times that garbage collection in PyS60 is not up
Is it possible for a Non-Interpreted language to have a Garbage collector. Interpreted languages
Possible Duplicate: What is the garbage collector in Java? Within my program, I have
Once again a question about the garbage collector in actionscript-3: If I have a
I've read some docs about the .NET Garbage Collector but i still have some
In my code, I have a object whose contents is fully garbage. I guess
I have a strange doubts. I know garbage collector has its own limitation. and
What guarantees are the for the garbage collector? From my research I have managed

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.