I’m using C# for a several years, never actually willing (until I really need to) to dig into its “deep” mechanics and to intervene in GC work, IL-compiled code and so on.

My point is if you ever need to even call GC manually (speaking general – to “help” C#’s or .NET’s mechanics and frameworks to do their job), then it is 99% probability that you doing something wrong versus 1% that you actually need this.

This is some kind of “old school” programmers’ whim – rather than study existing libraries and frameworks they will invent a bicycle again and again, flaunting with their “deep” knowledge, putting every “pattern” they heard of and producing some “masterpiece” which nobody will be able to understand (even creator himself several moths later).

However, back to the topic. GC generations is one of quite popular questions I was asked by some HRs, also I’ve read some “getting ready for the interview” articles touching this topic, but never seen anything about how you actually can deal with them yourself. I suppose, you can’t? I did some surface search and found only “understanding GC” kind of stuff. Like, you can know how compiler actually works, but do you going to “help” it to compile your program? And if not going to, then maybe better use your time to study some ASP.NET vNext kind of stuff?

So, do GC generations have any purpose (for an application programmer) other than answer to “tricky” HRs’ questions?

3

Knowledge of generational GC — the general idea, not how large exactly the young space is in Microsoft’s CLR version x.y — is much like knowledge of JIT compilation, operating system principles, assembly, hardware. You virtually never need it to produce a working product. However, it can accelerate bug hunts and optimization attempts by telling you what probably won’t work. Two examples:

Reusing/pooling objects sounds like a good idea to reduce GC work. If you don’t know a whole lot about GC internals, that is. But in a generational setting, an object that would otherwise be short-lived will be bumped up a generation or two if it goes into a pool. Deallocating it now takes a major GC, which is both rarer and more expensive, and an assortment of other small effects can also take place (depending on whether the object contain references and whether those references point at young objects).

Hence, a pool generally has to prevent many object creations to be profitable, which you now know without having to implement, profile and scrap pooling for something that probably won’t benefit from pooling.

Deeper knowledge also curbs nonsensical hypotheses. I wish I had a quarter for every confused beginner who I’ve seen hunting a (very real) bug by chasing imagined stupidity on the side of the GC. This is mostly related to reachability things, but I’ve also seen a few questions that could have jumped two edits ahead if poster had had a good grasp on generations.

Finally, don’t you think GCs are plain interesting to hear about? Maybe that’s just me, and to be honest it’s perhaps the biggest reason why I learned these things to begin with.

2

(I don’t know C# and I never coded for a Windows OS)

Read at least the wikipage on Garbage Collection, and if possible the GC handbook

A generational copying GC makes the hypothesis (generally rightly) that most young values are temporary and will die soon, and conversely that most old values will last more (and won’t die soon). So a generational GC is focusing its work on the youngest generation. Older generations are not processed often, because they contain long-living values which are likely to last more.

See also this SO question.

You might want (usually wrongly, because it does not worth the effort) to force GC when you know that a bunch of old values is becoming garbage. So generational GC are very useful (because they are efficient), but there are few cases where you want to force a GC in them (I won’t do that, unless benchmarking tells you that it is worth the effort).

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật