Сообщения за Март, 2013

6 interesting facts about garbage collection.

1. Don't create big objects with short lifetime Any object in CLR that is more than 85 000 KB in size are stored in the special heap for big objects. Also they are marked as 2nd generation objects from the start. Creating big objects with small lifetime is bad practice. Why? Garbage collector will need to collect 2nd generation objects more often, and this could lead to performance issues.
2. When GC collects garbage it pauses all managed threads When garbage collection starts CLR hijacks all managed threads and pauses them. But in fact it doesn't affect coding, so... nevermind :)
3. You can predict OutOfMemoryException  In some cases if application consume a lot of resources there is a probability of OutOfMemoryException. Not good, yeah? But... you can predict for operations with big memory consumption by using MemoryFailPoint.
Usage example:
   using(MemoryFailPoint mfp = new MemoryFailPoint(1500))    {     //Run code which uses lots of memory.    }
} catch(Insufficient…