Do you have a memory leak with garbage collector?

If I have a garbage collector that tracks every allocated object and frees them, as soon as they no longer have useful links to them, can you have a memory leak?

Given a memory leak, highlighting without any link is not impossible or am I missing something?

Edit: So, what I consider a memory leak is allocations that no longer contain code references. The large number of cumulative distributions you are still referring to are not the leaks that I am considering here.

I also only talk about the normal state of the GC art. It has been a while, but I know that cases like circular references do not cause them. I don’t need a specific answer for any language, it just comes from a conversation I had with a friend. We talked about ActionScript and Java, but I don’t need the answers specific to them.

Edit2: Due to the sounds of this code, the code apparently cannot completely lose the ability to refer to the distribution and not have the GC to pick it up, but I'm still waiting for more to weigh.

+5
source share
4 answers

If your question is really like this:

Given a memory leak, highlighting without any links is not that impossible or am I missing something?

", ", , .

, " " () Java. " " - , ( ) , " t , (.. ). :

ObjectA → ObjectB

ObjectA . ObjectA ObjectB, ( : ObjectB , , ), ObjectA null. ObjectB "".

, , . , ObjectA ObjectB . , null, , . - :

ObjectA → ObjectB → ObjectC → ObjectD → ObjectE → ObjectF → ObjectG → ObjectH → ..

ObjectB ObjectH . ( ) . .

+8

, , , . , S I, :

  • `S` ` I`, `S` ( ), ...
  • , "N", .

, , , , . , , - .

, - CollectionModified, IEnumerator<T>, IEnumerable<T>.GetEnumerator(), Dispose; , , (, , , , , ), , , . CollectionModified IEnumerator<T>, . .

+2

, , , , , , .

,

Object 1 refers to Object 2 and Object 2 refers to Object 1 

1 2, .

, .

0

You might have a memory leak using the GC in a different way: if you use a conservative garbage collector that naively scans the memory and everything that looks like a pointer does not free up the memory that it points to, you can leave the allocated memory inaccessible.

0
source

All Articles