TCS Placement: Sample Questions 90 - 90 of 502

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 90

Edit

Describe in Detail

Essay▾

What is garbage collection? Explain the difference between garbage collection in . NET 4.0 and earlier versions.

Explanation

  • Garbage collection prevents memory leaks during execution of programs.
  • Garbage collector is a low-priority process that manages the allocation and deallocation of memory for application.
  • Checks unreferenced variables and objects.
  • GC finds objects no longer used by the application and frees up the memory from that object. In . NET 4.0, the GC. Collect () method contains the following overloaded methods:
    • GC. Collect (int)
    • GC. Collect (int, GCCollectionMode)
  • . NET also notifies when the GC. Collect () method is invoked and completed successfully.
  • . NET 4.0 supports new background garbage collection replacing the concurrent garbage collection used in earlier versions.
  • Concurrent GC allocates memory while running and uses current segment (which is 16 MB on a workstation) for that. After that, all threads are suspended. In case of background GC, a separate ephemeral GC - gen0 and gen1 can be started, while the full GC - gen0,1, and 2 - is already running.

Developed by: