4 ms·
Memory leaks still happen if you have a misunderstanding of memory management, regardless of language. Keeping references to dead objects is one straightforward
by mirker 4y ago
Memory leaks still happen if you have a misunderstanding of memory management, regardless of language. Keeping references to dead objects is one straightforward way to do it. C++ also has smart pointers so it’s usually a case of someone writing code that is smarter than they are. One example: since some people in Python don’t think about memory they are prone to writing loops that grow memory proportionally to the loop counter in machine learning code (e.g., implicit graph references across loops).
- deltasevennine 4y ago>Memory leaks still happen if you have a misunderstanding of memory management, regardless of language. Apologies. What does this have to do with what I'm talking about? Not sure I said anything about memory leaks not happening in languages like python. I believe I said these issues happen "much less" in higher level languages so I'm not sure what you're trying to clarify here.
- mirker 4y agoWell I’m not aware of them happening “much less” just that there are less categories of bugs. We will of course rarely have software written with and without GC so it’s not an answer we will find. Memory leaks happen very frequently in managed languages e.g., http://ithare.com/java-vs-c-trading-ub-for-semantic-memory-leaks-same-problem-different-punishment-for-failure/#rabbitref-Sor17 http://ithare.com/java-vs-c-trading-ub-for-semantic-memory-l...
- deltasevennine 4y ago>Well I’m not aware of them happening “much less” just that there are less categories of bugs. We will of course rarely have software written with and without GC so it’s not an answer we will find. I would say your very inexperienced then. "Much less" is very obvious. Simply forgetting a delete operator or free in manual allocation leads to a memory leak. It is also proveable. Error surface area is smaller. delete and free don't exist in languages that exclusively use the GC for freeing memory thus you cannot "forget" to use those functions and thus error surface area is smaller, thus it must happen less frequently. >Memory leaks happen very frequently in managed languages e.g., http://ithare.com/java-vs-c-trading-ub-for-semantic-memory-l http://ithare.com/java-vs-c-trading-ub-for-semantic-memory-l... It happens but not frequently at all. I'm sorry. If you did manual memory management you would know this.