Questions tagged [garbage-collection]

For questions about garbage collection within the scope of designing/implementing a programming language, including implementing garbage collectors, the semantics or behavior of garbage collection algorithms, and language features exposing garbage collection to the programmer.

Filter by
Sorted by
Tagged with
5 votes
4 answers
2k views

Creating a new language with Rust without Garbage Collection?

I am new to language development. I am aware of Rust's ownership model that builds programs in a way that does not need garbage collection. So if I am to build a new programming language using safe ...
M4X_'s user avatar
  • 153
16 votes
6 answers
3k views

Possible to mix garbage collection and manual memory management?

Do you think it is possible to have a language that uses garbage collection (GC) by default, but allows you take more control with manual memory management like C++ or Rust, in areas of the software ...
Rob N's user avatar
  • 1,043
25 votes
8 answers
6k views

Is it possible to make GC a library?

Motivation Garbage collection is a critical component of memory management in many programming languages. Many languages have built-in garbage collectors tightly integrated into their runtime ...
Aster's user avatar
  • 2,552
7 votes
3 answers
175 views

What are the pros and cons of different ways of forcing resources to be closed properly?

There are various external resources, like file handles, TCP connections, and various servers, which need to be closed in some specific way before being dropped. There are a few approaches to these ...
Rydwolf Programs's user avatar
4 votes
2 answers
286 views

How to find the updated address of an object in a moving garbage collector?

I'm implementing a moving garbage collection algorithm, but I don't know how the GC can find an object's address after it has been moved. I thought of 3 options: Forwarding Pointer The first way is to ...
Aster's user avatar
  • 2,552
7 votes
1 answer
242 views

How does the performance of reference counting and tracing GC compare?

We already have a more general question about different types of garbage collection, but performance is only touched on briefly, and in pretty unspecific ways. What are the more specific ways in which ...
Rydwolf Programs's user avatar
20 votes
4 answers
3k views

How do precise garbage collectors find roots in the stack?

I know some garbage collectors (conservative GC) treat every word in the stack as a potential pointer to a live object in the heap (provided that the word actually points to somewhere inside an ...
Jeremy's user avatar
  • 411
23 votes
5 answers
619 views

Can "no cyclic data structures" be enforced at compile time?

When using reference counting for garbage collection, memory leaks can occur when cyclic structures are created (an object which contains a pointer to itself, or a pointer to an object with a pointer ...
Rydwolf Programs's user avatar
27 votes
4 answers
696 views

What different types of garbage collection are there, and what benefits do they provide?

Generally speaking, higher-level programming languages seem to utilize garbage collection. As a first example, Python uses reference counting (as well as three-level generational collection that just ...
Spevacus's user avatar
  • 605