By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,919 Members | 1,600 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,919 IT Pros & Developers. It's quick & easy.

Garbage Collector

P: 10
What will happen when memory is full,GC works,(2-3 times removing the objects from 2nd generation)still 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)?
Jan 23 '09 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 229
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).
Jan 23 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.