7 ms·
Programming on Unix and automatic memory management
- eska 4y agoI’ve never heard anyone claim that Unix is manual-memory-management-only..?
- wolletd 4y agoI'm also not sure why C++ is listed as exception. In practice, modern C++ is all about avoiding manual memory management. Since C++11 at least, possibly longer. Yeah, you still can do manual memory management, but thats by accident because it's a compiled language. You don't get manual memory management by accident when designing an interperted language because you would have to interpret it explicitly. This article just reads like it's from 2006.
- pjmlp 4y agoUnfortunely I can assure you than in 2023 there are plenty of code bases that don't care about RAII classes for automatic memory management in C++. Modern C++ is still pretty much a niche in the C++ universe, and what makes it so quixotic to push security programming practices to many C++ developers. Orthodox C++ even exists as a counter movement.
- deleted 4y ago[deleted]
- atahanacar 4y ago[flagged]
- sophacles 4y ago> I don't understand why someone had to write this, Becaue it answered a question for them and they chose to share. > and someone else decided to post it here. Because they found it interesting.
- atahanacar 4y ago>Becaue it answered a question for them What question? Who asked it? Who claimed it only had manual memory management? >Because they found it interesting. Why would someone find this interesting? It's very well known, especially given that almost the entirety of our internet infrastructure runs on it.
- sophacles 4y ago> Why would someone find this interesting? Because they never put it together? Because it contains new to them information? Because they like the style it was written in? I get it, you don't think it's interesting - but that fact itself is boring, most people find most things uninteresting, why do you feel the need to share? It might help you to pause and reflect on the fact that some people are not you, nor are they here to cater to you. As people they have their own interests and tastes, and maybe, just maybe, they differ from yours. > It's very well known, especially given that almost the entirety of our internet infrastructure runs on it. The knowledge in your head is not the knowledge in my head. Some of it may intersect and be shared knowledge, but you know things I don't and I know things you don't. This place has all sorts of readers from all sorts of backgrounds, some of them are young or new to the field - they need to get this info somehow, otherwise it stops being "very well known". One way of disseminating information is via blogs, another is sharing links to that blog on sites like HN. This may help you understand: https://xkcd.com/1053/ https://xkcd.com/1053/
- Jtsummers 4y agoThey indicated why they wrote it. At the end there is a parenthetical that says “sparked by this”. “this” is a link to here: https://news.ycombinator.com/item?id=35678093 https://news.ycombinator.com/item?id=35678093
- wheelerof4te 4y agoC has automatic memory management for the static memory and memory allocated on the stack. It's possible to program in C without manual memory management.
- jmclnx 4y agoFWIW, AIX has a utility that ypou can use to increase stack on a executable: ldedit I do not know if Linux or the BSDs have the same, or if it is even needed on those systems.
- fullstop 4y agoThe default stack limit in Linux is 8MiB, which is kind of huge as far as stacks go.
- wheelerof4te 4y agoYes, 8MiB per CPU process, if I'm not mistaken.
- bruce343434 4y agoNot for programs where the amount of items you must store is only known at run time.
- coldtea 4y ago>In short, programming with automatic memory management has been a part of Unix from Bell Labs onward. Not sure what this post is about. Automatic memory management is a property of the language, not the operating system. UNIX has had languages with AMM since forever, and those existed way before UNIX too.
- iainmerrick 4y agoIt's about a) this: UNIX has had languages with AMM since forever and b) the fact that those languages are core parts of UNIX. It isn't just a kernel, it's also tools like bash and awk. I think it's a decent rebuttal to people saying, e.g., "Java isn't UNIX-y because it needs a garbage collector". Which I don't think I've heard recently, but I have heard in the past.
- flohofwoe 4y agoIn a way, UNIX does have automatic resource managament: when a process is killed, its memory is returned to the system, file descriptors are closed, etc... In contrast, (IIRC) on the Amiga the OS didn't have per-process resource tracking, e.g. memory leaks would persist after a program was closed or had crashed.
- icedchai 4y agoI learned C on the Amiga, and this was one of the most annoying things about it. That and the lack of memory protection. It did make me pretty careful though!
- jmclnx 4y ago> From the days of V7 Unix onward (if not earlier), a substantial amount of Unix programming has always been done in languages with automatic memory management. It's just that we called this programming "shell scripts", "awk", "make", and so on I remember correctly, in the early days, it was frowned upon to program in c if the same could be done using shell scripts and awk, sed and friends. But these are the days of multi-gig applications a no one cares about using UN*X as originally designed.