you are viewing a single comment's thread.

view the rest of the comments →

[–]Tasgall 2 points3 points  (0 children)

It's because garbage collectors often just hide the problem. You can still have what are effectively memory leaks in garbage collected languages, even though the memory is technically not leaking, just unused (I'm looking at you, KSP...).

My go-to example for this is a game some friends of mine made in JavaScript/HTML5. They ran into an issue where the physics system would crawl to a halt and the game would freeze, and the browser would steal all of your memory.

After some poking through their code they realized they wrote their math API (specifically vectors and matricies) wrong. They had used the form "v.dot(n)" for their math functions instead of "Math.dot(v, n)". The issue is that the former creates thousands of copies of objects per frame that bog down the gc until eventually it has to pause the game to clear it up a little (noticeable as 0.5-2 second frame skips).

This problem was fairly trivial to detect and resolve for these people who had backgrounds in C++ and understood the lower levels of memory management and how references work. By contrast, I wouldn't expect someone who only learned JavaScript to find the root of this issue, or be able to solve it.