3 ms·
I can't say that the Java Virtual Machine would have done much better, since it operates under pretty much the same theory (generational garbage collection). A
by Roboprog 15y ago
I can't say that the Java Virtual Machine would have done much better, since it operates under pretty much the same theory (generational garbage collection).
At least Ruby has the option to mark some strings as outside of garbage collection -- to make them permanent symbols/atoms.
We need an option in these modern GC languages to select a reference counting option, or perhaps for portions of code to kick it old school and simply ask for some objects to allocated outside the GC heap on the assumption that they will be around for a while and that the programmer will manually throw that subset of objects away if they become unwanted.
TMTOWTDI. (and all ways seem to have their place at times)
- kmontrose 15y agoYou can intern strings manually in .NET (I think you can in Java too), which effectively makes them ineligible for collection. There are serious memory concerns with that approach, since nothing in the tag engine is a constant. In C# you can use the unsafe keyword to get more or less back into the C/C++ world. While your new'd objects are still GC'd, you have the option of just grabbing an allocator and getting unmanaged memory if you feel like it. It's worth noting that the .NET GC works quite well for typical cases, and only noticeably chokes on this one use case we have and only under load that most websites will never see (and most users don't notice even on SO, but we watch the logs religiously to make sure these things don't become noticeable). There are also some improvements coming in .NET 4.5's GC that may mitigate this, but we're naturally not willing to wait for it. I worry people may be taking "don't use .NET, its GC sucks" away from this blog post, which really isn't the point (or accurate).
- dbattaglia 15y agoI worry people may be taking "don't use .NET, its GC sucks" away from this blog post, which really isn't the point (or accurate). I get the feeling some already came in with that opinion, so they will take away what they want to. I personally got the impression that this is something that would have caused pain in almost any language with a generational GC.
- Roboprog 15y agoI definitely do NOT mean to imply that the .NET GC is inferior. The very fact that you have options of how to manage memory at all in C#/.NET makes it superior to the JVM in that regard. Admission: I'm am reluctant to want to work on Windows, though. But since that is the Stack Exchange environment, C#.NET seems hands-down the best platform for it.