how Garbage collector works under the hood to collect dead object?

Muneeb Nasir

I was reading up on garbage collection. As we know, Garbage collection collects dead object and reclaims memory. My question is, how Collector comes to know that any object is dead? what data-structure it use to keep track of live objects?

I was researching about this, I found, GC actually keep track of live objects, and marked them. every object that is not marked consider as dead. I guess, there is some thing called object-tree is used for this purpose. but how its works I don't know.

Here are my list of questions.

  • what is object-tree?
  • how its works? when we create any object with new keyword, how it affects that object-tree?
  • who maintains this tree? jvm, GC, or that's how objects get stored in heap?
the8472

The tree is just a conceptual view on the memory heap and the references between objects. It does not exist as a separate entity.

And it's not really a tree since it can contain cycles, so calling it a graph would be more accurate. During garbage-collection it is visited in a tree-like manner (breadth-first or depth-first traversal) by following references and skipping those already visited.

http://en.wikipedia.org/wiki/Tracing_garbage_collection

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Are pointers in D under the jurisdiction of the garbage collector?

From Dev

When does the garbage collector free the 'request' object?

From Dev

How does Garbage Collector works for Primitive Data type in Java?

From Dev

Is it possible to identify that object is collected by garbage collector or not in java?

From Dev

Understanding how java debugging really works under the hood

From Dev

How to microbenchmark java garbage collector?

From Dev

How garbage collector detects garbage?

From Dev

Javascript garbage collector on internally referenced object

From Dev

How does querySelector works under the hood?

From Dev

Garbage collect certain object

From Dev

How response from http.request works under the hood with two writable streams?

From Dev

How does mongoose populate work under the hood

From Dev

Garbage Collector doesn't immediately collect finished thread

From Dev

How does gperftools work under the hood?

From Dev

How java AtomicReference works under the hood

From Dev

extremely confused about how this "oop under-the-hood" example of a counter works

From Dev

How does addEventListener work under the hood?

From Dev

Delete a file after object is destroyed by garbage collector

From Dev

Does the Garbage Collector benefit from multiple calls to Collect and WaitForPendingFinalizers()?

From Dev

Why Garbage Collector doesn't collect Tasks objects

From Dev

Does it get copied? How passing reference and value types works under the hood

From Dev

How garbage collector detects garbage?

From Dev

Garbage collect certain object

From Dev

Garbage Collector: Taking care of object with a reference to singleton

From Dev

Does the Garbage Collector benefit from multiple calls to Collect and WaitForPendingFinalizers()?

From Dev

Garbage collector tries to collect shared memory object

From Dev

How Gradle tasks inline configuration works under the hood ?

From Dev

Collection was modified exception. How it works under the hood?

From Dev

How encrypted AWS PostgreSQL RDS works under the hood?

Related Related

  1. 1

    Are pointers in D under the jurisdiction of the garbage collector?

  2. 2

    When does the garbage collector free the 'request' object?

  3. 3

    How does Garbage Collector works for Primitive Data type in Java?

  4. 4

    Is it possible to identify that object is collected by garbage collector or not in java?

  5. 5

    Understanding how java debugging really works under the hood

  6. 6

    How to microbenchmark java garbage collector?

  7. 7

    How garbage collector detects garbage?

  8. 8

    Javascript garbage collector on internally referenced object

  9. 9

    How does querySelector works under the hood?

  10. 10

    Garbage collect certain object

  11. 11

    How response from http.request works under the hood with two writable streams?

  12. 12

    How does mongoose populate work under the hood

  13. 13

    Garbage Collector doesn't immediately collect finished thread

  14. 14

    How does gperftools work under the hood?

  15. 15

    How java AtomicReference works under the hood

  16. 16

    extremely confused about how this "oop under-the-hood" example of a counter works

  17. 17

    How does addEventListener work under the hood?

  18. 18

    Delete a file after object is destroyed by garbage collector

  19. 19

    Does the Garbage Collector benefit from multiple calls to Collect and WaitForPendingFinalizers()?

  20. 20

    Why Garbage Collector doesn't collect Tasks objects

  21. 21

    Does it get copied? How passing reference and value types works under the hood

  22. 22

    How garbage collector detects garbage?

  23. 23

    Garbage collect certain object

  24. 24

    Garbage Collector: Taking care of object with a reference to singleton

  25. 25

    Does the Garbage Collector benefit from multiple calls to Collect and WaitForPendingFinalizers()?

  26. 26

    Garbage collector tries to collect shared memory object

  27. 27

    How Gradle tasks inline configuration works under the hood ?

  28. 28

    Collection was modified exception. How it works under the hood?

  29. 29

    How encrypted AWS PostgreSQL RDS works under the hood?

HotTag

Archive