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.

10 votes
2 answers
691 views

Idiomatic memory allocation and garbage collection in LLVM

I am working on a new backend for a programming language using LLVM IR. This language makes a distinction between basic values and pointers to nodes on the heap, and uses a copying collector for ...
user65560's user avatar
  • 200
14 votes
3 answers
3k views

A kind of "weak reference" which keeps the object alive, as long as there is otherwise-unused memory

Modern operating systems usually use some of the main memory for caching files, as loading those files from the cache will be faster than loading them from disk; but this memory can be reclaimed by ...
kaya3's user avatar
  • 22.4k
8 votes
2 answers
743 views

Analysis of methods to ensure memory safety

Overview Ensuring memory safety is a core facet of modern programming language design. Memory safety can be guaranteed in many different ways. For the purposes of this question, I am defining memory ...
Wesley Jones's user avatar
3 votes
2 answers
617 views

How does a simple mark-and-sweep GC stop the other threads?

I'm reading the GC Handbook and trying to implement the first collector type described there, a basic mark and sweep. I know this is not the greatest way to implement a garbage collector, but I want ...
Rob N's user avatar
  • 1,175
6 votes
3 answers
1k 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
4 votes
1 answer
1k 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
  • 3,314
3 votes
2 answers
447 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
7 votes
2 answers
771 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
  • 3,314
8 votes
4 answers
5k 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
  • 191
16 votes
6 answers
4k 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,175
27 votes
8 answers
7k 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,458
7 votes
3 answers
314 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's user avatar
  • 4,870
5 votes
2 answers
470 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,458
9 votes
1 answer
665 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's user avatar
  • 4,870
22 votes
4 answers
4k 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
  • 431

15 30 50 per page