4 ms·
Memory leaks aren’t unsafe fwiw.
by dagmx 3y ago
Memory leaks aren’t unsafe fwiw.
- ChrisMarshallNY 3y agoThey often result in eventual crashes (but relatively controlled ones), and can affect performance. So “unsafe” is relative. In any case, memory leaks are sloppy, and I have a personal aversion to writing sloppy code.
- saagarjha 3y agoCrashes are not unsafe either.
- ChrisMarshallNY 3y agoThis is true, everything is sandboxed, these days (but I'm not as sure about MacOS, as I am about iOS). But it's still a bad look, and Apple won't approve an app, if they can get it to crash -regardless of the reason.
- saagarjha 3y agoThat comes back around to whether the user or the platform is the reason for the crash. If a user puts in something weird then it’s your job to fix that, almost always.
- dagmx 3y agoI’ll be a bit pedantic and say, that even by the Swift (or rust) language: 1. Crashes aren’t unsafe. They’re actually preferable for both Swift and rust than getting into an unsafe state with incorrect data. So in that sense, crashes are the seen as safe, just undesirable as an outcome. 2. Memory leaks can’t be unsafe any more than a badly optimized algorithm. But yes, they’re sloppy and should be avoided. I just contend that there’s no real case where I think they should be considered unsafe from the model of a programming language. They might be unsafe from the model of a context specific use. E.g you wouldn’t want a memory leak locking up your system in vehicular automation. But I’d fall back to it just being sloppy programming if that state is achieved.