Garbage Collector

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gayatri pande
    New Member
    • Jan 2009
    • 10

    Garbage Collector

    What will happen when memory is full,GC works,(2-3 times removing the objects from 2nd generation)stil l insufficient memory?
    Does it give
    a. "Out of memory exception" immediately OR
    b. waits for sometime expecting some memory to be released (and then give exception if still insufficient memory)?
  • vekipeki
    Recognized Expert New Member
    • Nov 2007
    • 229

    #2
    GC will raise the exception if it cannot allocate the specified memory, at the moment of allocation. Your calling thread is blocked until the memory is allocated using the new keyword, and GC surely doesn't wait to see if something will get freed.

    In practice, out of memory means that something has really gone wrong with your program, so you shouldn't worry about what GC will do in these situations, but rather improve your program design or find out

    This link will give you enough info about .NET collector, but you can also Google it for more resources (like Wikipedia - Garbage collection).

    Comment

    Working...