Also, theUnsafe makes me snicker
.Unsafe.class.getDeclaredField("theUnsafe");Also, theUnsafe makes me snicker
.Unsafe.class.getDeclaredField("theUnsafe");The general argument is that you are still more productive by writing 90% or 95% of you app in a managed language, in the idiomatic way. Then you use crazy tricks to tune the last 10/5%. Rather than doing the whole thing in C/C++, which will give better performance, but may not be quicker (more productive) to write.
I don't know much about D, it's interesting to find that you can opt out of GC like that.
You get some of that functionality in .NET, with the new GC mode SustainedLowLatency [1]. But it doesn't guarantee no GC, it just tried to avoid it.
> Enables garbage collection that tries to minimize latency over an extended period. The collector tries to perform only generation 0, generation 1, and concurrent generation 2 collections. Full blocking collections may still occur if the system is under memory pressure.
[1] http://msdn.microsoft.com/en-us/library/system.runtime.gclat...
Basically, if you're at the point where the GC is impacting you but if you haven't tried Roslyn-level optimizations -- do that first.
But I agree that working with the grain of the GC is usually more productive.
There's no good reason for the managed heap to be anywhere near any of the native heaps in address space, on 64-bit platforms.
And the CLR's GC should actively allocate slabs well away from any native heap (trivial to do - reserve (not commit, reserve) a big contiguous chunk of address space), simply because it relies on third party code which will itself be allocating native memory; everything from GUI code to native DB drivers and their caches, quite independent of unsafe code doing manual allocation.
In the absence of a GC-aware virtual memory manager, GC-immovable memory has little relevance to paging.
(Of course, GC.Add/RemoveMemoryPressure should be called if you're doing native allocation from .net.)
[1] http://msdn.microsoft.com/en-gb/library/f58wzh21(v=vs.71).as...