Understanding garbage collection in .NET

You are being tripped up here and drawing very wrong conclusions because you are using a debugger. You’ll need to run your code the way it runs on your user’s machine. Switch to the Release build first with Build + Configuration manager, change the “Active solution configuration” combo in the upper left corner to “Release”. … Read more

How ‘random’ is allocation of memory when I say “new Integer” in Java?

What algorithms are used? Java uses TLAB (Thread Local Allocation Buffers) for “normal” sized objects. This means each thread grab some Eden space and turns this grab of memory into individual objects. Thus small objects are typically sequential in memory for that thread, except if a new chunk of memory needs to be grabbed. Large … Read more