On Sat, Apr 25, 2020 at 04:37:43PM +0000, Caveman Al Toraboran wrote: > so i really can't believe that we have devolved in > such a way where malloc/free suddenly has became a > hard concept for homo sapiens. You'd be surprised how much shocking code is out there, especially in proprietary products (the Valve Steam Client is a prime example). In general, reasons for memory-management-incompetence fall into the following categories: (a) Programmers forget. For experienced and skilled developers, this is likely the most common cause of malloc-free mismatches. I was programming in C a few years before I ever touched a computer (I bought/stole Kernighan and Ritchie from the local library and wrote out code-listings with pencil and paper), and to this day still occasionally forget to free everything I malloc. Thankfully, in the days of dynamic code-analysis tools such as Valgrind, these problems---amongst other hard-to-spot issues---become easy fixes. (b) Programmers don't care, because it is assumed the operating system will do it for them. I have heard this one quite a bit from people trying to justify their horribly written code. Often, with people who make this argument, the malloc-free mismatch is the least of their problems, however in the days of intelligent operating system-level memory-management seen in modern Linux kernels, some programmers seem to take the hard work of kernel developers as a free pass to be messy themselves. (c) Programmers don't care, because the code means nothing to them. I have never worked as a professional programmer, so I can only speculate, but from conversations with veteran developers at large companies such as Intel and Microsoft, it seems as though the general morale amongst older developers can drop hugely. Why bother optimising or thoroughly testing code when it's not yours, and you don't really care about the company for whom you're developing ? (d) Programmers are genuinely unaware of the importance of freeing their malloc'd objects. With the abundance of terrible on-line tutorials, written by teachers that seem to devote themselves to teaching the worst practices possible, I've seen an influx of programmers who are simply unaware of the need to free their memory pools. It takes less than a minute of on-line searching to find a popular tutorial on some pretty website which shows code leaking memory. So yes, it is easy to understand, but whether people _care_ or even know in the first place is entirely up to them. -- Ashley Dixon suugaku.co.uk 2A9A 4117 DA96 D18A 8A7B B0D2 A30E BF25 F290 A8AA