Skip to main content

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
6 votes
2 answers
894 views

What are the limitations of combining tracing GC with manual memory management?

TL;DR: Could a programming language that uses manual memory management use a tracing GC to rescue the usual suspects of memory leaks? I was reading about the Boehm GC and came across this page that ...
Sudoh's user avatar
  • 163
3 votes
1 answer
869 views

How do languages with only reference counting deal with closures?

Reference counting works best if there are no cycles. But closures that allow access to every variable in the parent scope by default automatically create cycles. There are obvious solutions like only ...
user23013's user avatar
  • 2,390
3 votes
2 answers
254 views

Does a Rust implementation of the Monkey programming language require a garbage collector?

Awhile back I wrote a Rust implementation of the Monkey programming language by Thorsten Ball (https://monkeylang.org/). When I got done with it I was a bit surprised that I never used an Arc/Rc ...
lamont's user avatar
  • 139
6 votes
2 answers
430 views

When do functional programming languages need advanced garbage collection?

While thinking about garbage collection, I realized a simple fact that a garbage collector that is more than reference counting is needed because there are circular references, but there are ...
user23013's user avatar
  • 2,390
6 votes
4 answers
4k views

Does using Rust eliminate the need to implement garbage collection in a language?

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
  • 171
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,083
27 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
  • 3,198
7 votes
3 answers
209 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
5 votes
2 answers
331 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
  • 3,198
8 votes
1 answer
314 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
21 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
  • 421
25 votes
5 answers
741 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
28 votes
4 answers
928 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
  • 615