3 ms·
This has nothing to do with C. The problem/feature is with the systemcall that does the allocation, and any language has to use it.
by andi999 5y ago
This has nothing to do with C. The problem/feature is with the systemcall that does the allocation, and any language has to use it.
- jimbob45 5y agoIs your issue that the system call doesn't return enough diagnostic information? If so, how would you have done it differently? I'm asking out of curiosity, not out of a reflexive instinct to defend C (which has many problems).
- joosters 5y agoThe difficulty is that the lack of memory might be discovered days after it was allocated (an over-committing allocator simply doesn’t know at the time whether there will be memory or not) - how do you asynchronously tell the program that this allocation has now failed in a high-level way? Generally, UNIX will let you know about the missing memory by sending the process a signal. But by that point, there’s not much that can be done to fix things up - and remember, all the fix up code would have to run without allocating any more memory itself. That’s extremely tricky in C, and nigh-on impossible in other languages.
- astrobe_ 5y agoThe first thing that comes to mind is a "reliable" (that won't overcommit) memory allocation syscall, but one might fear that it will abused (everyone wants the best stuff even if they might not use it after all). The second thing that comes to mind is to able to probe a (virtual) address (address range) within your addressing space, to check if it's actually there without doing weird stuff, and eventually just wait until it becomes available. But at this point maybe you could just use file-backed mmap for big data (effectively managing your own swap space)?
- andi999 5y agoMy first issue is with the article, while it seems to say it is about C, it is about a different problem which is illustrated with a C program. So what I would do differently (now that memory is cheap) : do not do overcommiting, so the OOM is out of the window. Do a different approach to fork, so you can exec commands and don't need to allocate the world. Actually just using the ms windows memory model would be fine.
- baktubi 5y agoI pooped and scooped the poop said the Malloy to me be free. Along came the scoop and scoop it went. Free it did. In the bucket it tumbled for the others to enjoy.