Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Part of the reason programs use so much memory is because of optimization, but of a different kind. Memory is fast-ish, so if you know or think that you will require X Y Z anyway then just load it in RAM. And, if you think you might need it later, don't bother unloading it. Just keep it around.

Garbage collectors also use similar strategies. Collecting garbage is expensive, so just don't until you need to. The extra memory usage in this case isn't a downside, it's an upside. Your code runs faster.

That's how Java and dotnet are able to achieve insane performance times in some benchmarks, like within 50% of native. They're not collecting garbage, and their allocators are actually faster than malloc.

If you've ever run a Java program at consistent 90% heap usage, you'll notice it absolutely grinds to a halt. I'm talking orders of magnitude slower. Naturally, this isnt highlighted in benchmarks, but it illustrates the power of allocating more memory.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: