|
|
|
|
|
by blub
2920 days ago
|
|
You're trying really hard to find a connection between implementing a GC and debugging memory leaks... and failing. The whole freaking point of a GC like say Java's is that an average programmer can use it without having to understand how exactly it's implemented.
Of course it won't hurt to know that, but it's not at all mandatory knowledge. One just has to know which situations the GC can't cope with and avoid them. For Java there's at least one open source dedicated tool for finding leaks, it nicely explains what one needs to know. |
|
Unfortunately, many programmers believe that since Java uses garbage collection, you do not have to think about GC and ownership at all.
Oracle had to replace the fast implementation of substring that just returns a slice of a String (O(1) time) by a copying implementation (O(n)), because too many programmers do not know the basics of ownership/garbage collection and would accidentally hold on to larger strings.
Seeing the implementation details of reference counting, mark-sweep collection, and perhaps a generational collector once, makes you more aware of memory and ownership issues, even if you forget the nitty gritty details later.