News for hackers. Stuff that matters.
Re:Zed Shaw on C++ by gaius on Friday July 16, 2010 @05:27AM (#1520723)
Perhaps you need to run deterministically without a stop-the-world garbage collector? A) the world is bigger than simple web applications and B) some of us have been doing this for a long time.
Re:Zed Shaw on C++ by bad_user on Friday July 16, 2010 @06:54AM (#1520809)
I wasn't talking about web applications, and modern garbage collectors are not stop-the-world.

Not to mention ... stop-the-world garbage collectors have a good reason for doing what they do. They are defragmenting the memory. You get that for free, when in C++ you would have to deal with hell if your app is doing lots of allocations ... see the shit the Firefox devs had to go through to alleviate the problems of heap fragmentation, and its still a problem.

Re:Zed Shaw on C++ by heresy on Friday July 16, 2010 @08:24AM (#1520895)
Ah, but what, you're using both managed code (C#) and unmanaged code (C++) in the same address space, doing memory intensive work using third party proprietary C++ code that does lots of small allocations?

In 32-bit land, it's welcome to OutOfMemoryException because managed code can't allocate a big enough chunk when returning to C#.

No free lunch :)

Either recycle processes often or reserve big enough contiguous chunks in managed code before calling out to the bad C++ code, no amount of good citizenship in managed code will stop the poorly written native code from fragmenting the hell out of your address space.

Re:Zed Shaw on C++ by gaius on Friday July 16, 2010 @09:37AM (#1521073)
Unfortunately we don't all have the luxury of rewriting all our code in the trendy language du jour.
Re:Zed Shaw on C++ by wglb on Friday July 16, 2010 @07:45AM (#1520853)
Can you give an example of stop-the-world garbage collection?
Re:Zed Shaw on C++ by noss on Friday July 16, 2010 @08:42AM (#1520935)
I've experienced problems with java's concurrent mark and sweep collector. It will stop the world, two times, but two much shorter times than a non-concurrent mark and sweep. So it is definitely an improvement in the duration of the stop-the-world.

The problem tends to be that you need to tune it, and even as you have tuned it, you can not promise that under special condition it will fall back to a more primitive collector since the optimality it was tuned for doesn't hold anymore.

I would never argue giving up garbage collection entirely because of these failure scenarios. I would much rather look at moving some critical part of the code out to a language with manual allocation, and let it perform the latency-sensitive bits.

Another mid-ground is to have separate isolate processes (heaps really) that can be stop-the-world collected without blocking each other. Erlang makes great use of this to accomplish "soft realtime", among other things.

Re:Zed Shaw on C++ by bhousel on Friday July 16, 2010 @08:20AM (#1520886)
Javascript... Yes, even V8.

Side rant: it's part of the reason that my Palm Pre will sometimes just hang for a second at the worst times, such as when I go to answer the phone. :(

Re:Zed Shaw on C++ by silentbicycle on Friday July 16, 2010 @08:23AM (#1520893)
A simple mark & sweep or stop & copy GC. Collectors which are incremental (work in small steps, not one full pass at a time) and/or generational (using several smaller generations, which are collected individually) break up GC pauses into something less disruptive.

For a good overview, read "Uniprocessor Garbage Collection Techniques" by Paul Wilson (check google scholar). Richard Jones's _Garbage Collection: Algorithms for Automatic Dynamic Memory Management_ is more in depth.

Re:Zed Shaw on C++ by kenjackson on Friday July 16, 2010 @03:42PM (#1522284)
If you meant actually existing stop the world GC, the server GC in Microsoft's CLR stops all threads on a processor to do GC.