Fundamentals of garbage collection (2023)
learn.microsoft.com
Fundamentals of garbage collection (2023)
1–10 of 34 posts
Re: Fundamentals of garbage collection (2023)
#2Re: Fundamentals of garbage collection (2023)
#3It probably wouldn't be usable for a general-purpose programming language, but for a special-purpose scripting language I could see it making the language implementation easier.
Re: Fundamentals of garbage collection (2023)
#4Kindof unrelated to the article, but I was recently wondering if it would be possible to detect and deny pointer cycles in a language in an efficient way, so that you could then use simple reference counting instead of full-blown garbage collection. It probably wouldn't be usable for a general-purpose programming language, but for a special-purpose scripting language I could see it making the language implementation…
But if it was a simple scripting language and you needed that constraint, it’s relativity easy to implement.
Re: Fundamentals of garbage collection (2023)
#5Kindof unrelated to the article, but I was recently wondering if it would be possible to detect and deny pointer cycles in a language in an efficient way, so that you could then use simple reference counting instead of full-blown garbage collection. It probably wouldn't be usable for a general-purpose programming language, but for a special-purpose scripting language I could see it making the language implementation…
Another solution is to make things immutable (like Erlang), or "as-if" immutable (like Koka), which guarantees that data can only point to things that have already been defined, preventing cycles.* Erlang uses this to simplify generational collection - because old data can't point to young data, it doesn't need a card table or anything like that.
I think it's perfectly possible to have a general purpose language without cycles: you can just use integer indices into an array instead of pointers if you want cyclic data structures. This is common in Rust, when people want to avoid the overhead of reference counting, but don't want to use unsafe code.
* A hidden assumption here is that the language is eagerly evaluated. There are languages like Haskell that have immutability and cyclic data structures.
Re: Fundamentals of garbage collection (2023)
#6Kindof unrelated to the article, but I was recently wondering if it would be possible to detect and deny pointer cycles in a language in an efficient way, so that you could then use simple reference counting instead of full-blown garbage collection. It probably wouldn't be usable for a general-purpose programming language, but for a special-purpose scripting language I could see it making the language implementation…
One solution is to forbid recursive data types - e.g., require every struct type to only reference types that have already been defined. I can't think of any languages that do this. Another solution is to make things immutable (like Erlang), or "as-if" immutable (like Koka), which guarantees that data can only point to things that have already been defined, preventing cycles.* Erlang uses this to simplify generationa…
Re: Fundamentals of garbage collection (2023)
#7Earlier quoted context omitted.
One solution is to forbid recursive data types - e.g., require every struct type to only reference types that have already been defined. I can't think of any languages that do this. Another solution is to make things immutable (like Erlang), or "as-if" immutable (like Koka), which guarantees that data can only point to things that have already been defined, preventing cycles.* Erlang uses this to simplify generationa…
Even with cyclic relationships between types, immutability makes cycles within instances difficult (without laziness anyway). A syntax tree would be a good example.
Edit: I think the common idea with both solutions is that our objects have some weak order (the order in which their types were defined, and the time at which the object was created, respectively), and objects are only allowed to point to objects strictly less than them in this order.
Re: Fundamentals of garbage collection (2023)
#8There is bunch of people copy pasting documentation to SO "explaining" server GC. I am running bunch of .NET stuff in VMs and never set "Server GC" and never ran into issues with default but also not sure if it is worth testing out.
I guess it does not matter much if you are running in containers but I am running on VMs in IIS.
Re: Fundamentals of garbage collection (2023)
#9Earlier quoted context omitted.
One solution is to forbid recursive data types - e.g., require every struct type to only reference types that have already been defined. I can't think of any languages that do this. Another solution is to make things immutable (like Erlang), or "as-if" immutable (like Koka), which guarantees that data can only point to things that have already been defined, preventing cycles.* Erlang uses this to simplify generationa…
Even with cyclic relationships between types, immutability makes cycles within instances difficult (without laziness anyway). A syntax tree would be a good example.
Re: Fundamentals of garbage collection (2023)
#10Question: does anyone run "Server GC" for the ASP.NET applications? There is bunch of people copy pasting documentation to SO "explaining" server GC. I am running bunch of .NET stuff in VMs and never set "Server GC" and never ran into issues with default but also not sure if it is worth testing out. I guess it does not matter much if you are running in containers but I am running on VMs in IIS.