.NET GC Internals mini-series
11–20 of 77 posts
Re: .NET GC Internals mini-series
#12Why .NET still has no interface for serious, custom GCs?
This feature is enabled in the official builds though.
Re: .NET GC Internals mini-series
#13Why .NET still has no interface for serious, custom GCs?
CoreCLR does have the ability to compile the GC as a DLL and then choose different GCs are runtime by loading different DLLs. Search for FEATURE_STANDALONE_GC in the code base. This feature is enabled in the official builds though.
Ain't that relatively young, not so mature and and designed with specific GC design in mind interface?
Re: .NET GC Internals mini-series
#14Likely GC abbreviates garbage collection.
Going way back, some programming languages have permitted dynamic storage allocation, that is, a programmer using that language could during execution of the program ask for storage, that is, bytes in main memory, to be allocated, i.e., made available for use. Later the programming could free that storage. E.g., early versions of the programming language Fortran did not offer dynamic storage allocation, but some programmers would implement their own, say, in a Fortran array. Then for pointers to the allocated storage, just use a subscript on the array name. The array might be in storage called COMMON which to the linkage editor was external, thus permitting all parts of the program to use dynamic storage. The programming language PL/I had versions of dynamic storage AUTOMATIC, BASED, and CONTROLLED. The programming language C has storage allocation via the function MALLOC and freeing via FREE.
Well, first cut, intuitively can think of garbage collection (GC) as automated dynamic storage freeing.
In the case of the original post (OP) of this thread, what is going on is, in the .NET languages, C#, Visual Basic (VB), F#, etc., can, e.g., in a function, allocate storage, e.g., with the VB statement ReDim, likely use that storage, have flow control leave that function, leave the storage allocated, and, then, have garbage collection notice automatically when that storage will not be used again and free it, i.e., make it available again for allocation and use. In addition, likely the code for some programming language features need at least dynamic storage and might use GC for freeing.
The broad idea of garbage collection is old, in several programming languages goes back decades. E.g., in PL/I, AUTOMATIC gave automatic storage freeing.
Why should .NET implement garbage collection, that is, why bother? Otherwise sometimes programmers forget to do the garbage collection themselves resulting in allocated storage growing until it is too large. One of the old examples was from cases of handling exceptional conditions; in some cases the code that got control did not have the data to know what storage should be freed.
GC has some challenges:
First, in a rich language, it can be not easy to know what storage should be freed. So, there can be some bugs in GC implementations.
Second, GC takes time, and maybe in some situations, that is, in some programs, takes too much time and results in, say, noticeably slower response time. One place where GC tends to be unwelcome is real time programming where want the software to respond in no more than a few milliseconds to external events that occur at unpredictable times.
One of the main ideas for GC implementation is reference counting where the programming language compiler inserts extra code that, for each instance of appropriate cases of allocated storage, keeps track, say, just a count, of essentially how many variables in the code (for each thread of execution) might use, reference, the storage. Then for such an instance of storage when its reference count reaches zero, free the storage.
Re: .NET GC Internals mini-series
#15How do I know this person really knows about .NET GC internals for me to spend any time watching some videos?
The author is MVP in .NET and author of the book Pro .NET Memory Management.
Re: .NET GC Internals mini-series
#16Earlier quoted context omitted.
CoreCLR does have the ability to compile the GC as a DLL and then choose different GCs are runtime by loading different DLLs. Search for FEATURE_STANDALONE_GC in the code base. This feature is enabled in the official builds though.
You meant "local GC" initiative? Ain't that relatively young, not so mature and and designed with specific GC design in mind interface?
Re: .NET GC Internals mini-series
#17Re: .NET GC Internals mini-series
#18Is this the GC that’s contained in one single 50,000 loc file?
https://raw.githubusercontent.com/dotnet/runtime/master/src/...
Re: .NET GC Internals mini-series
#19How do I know this person really knows about .NET GC internals for me to spend any time watching some videos?
Not that this proves anything, but this author's twitter account is followed by: * David Fowler (ASP.NET Core creator) * Andy Gocke (Lead developer for the CLR) * Jared Parsons (Lead developer for C# Compiler team) * Miguel de Icaza Presumably if he wasn't saying anything worth listening to, they would have unfollowed him by now.
Re: .NET GC Internals mini-series
#20Maybe for some readers: Likely GC abbreviates garbage collection . Going way back, some programming languages have permitted dynamic storage allocation , that is, a programmer using that language could during execution of the program ask for storage , that is, bytes in main memory, to be allocated , i.e., made available for use. Later the programming could free that storage. E.g., early versions of the programming la…
Even today people do the same thing in languages like Java and Rust as workarounds for performance or semantic constraints of the environment while still nominally obeying language semantics. I assume the same phenomenon is true in the C# universe.
When you bring this up many users of those languages are quick to explain why array indices are safer than managing raw memory addresses from outside the language's object model, but let's not go there ;)