I just started with the .NET Framework with C # as my language. I understand the concept of GC in Java somewhat, and today I revised the concept in .NET.
In C #, value types are pushed onto the stack (as is the case with Java, where local variables are pushed onto the stack). But in C # it is even structincluded in value types. Thus, they structare even pushed onto the stack. In the worst case, when there are many method calls, and the stack is filled with many methods, and each method has many local value types, and many structthat themselves have many local values will collect the garbage collector affects the stack? From what I studied (and partly from what I was taught), I understand that this will not be done. First of all, because manipulating the contents of the stack will be associated with large overheads, and, in addition, the GC only consults the stack to find links - and nothing more.
Just add another question related to the same topic: forcing a GC call (for example, System.gc()in Java, not sure about the C # equivalent) does not guarantee that the GC routine is called then and there. So, where should I place such a call - where do I expect that I need a GC to run, or in any random place, since there is no guarantee that my call will immediately invoke the GC? Or should I just leave the stuff in the Runtime Environment and not worry about it?
Note. I added the Java tag because I am trying to link concepts from there. I understand that the internal functioning of the GC in two separate Runtime environments will definitely be different, but I assume that the basic concept will be the same.
source
share