3 ms·
> Some programs will malloc a huge area and only use a small portion of it, and in this scheme, that memory is "in use." It's also worth noting that most progra
by paulddraper 10y ago
> Some programs will malloc a huge area and only use a small portion of it, and in this scheme, that memory is "in use." It's also worth noting that most programs don't tolerate malloc failure well at all, and will just crash anyway.
...and it would be absurd for bad programs to eat memory and crash? We must have other programs pay for its sins?
- mikeash 10y agoTha program that hits a malloc failure will not necessarily be the program that ate up all the RAM.
- tedunangst 10y agoMalloc failure is at least synchronous with the out of memory condition. And if your program has reached a fixed state, it may not even be calling malloc.
- cturner 10y agoOt: your flak blog could benefit from a page showing links to all articles. Currently, hard to read beyond 'recent'.
- tedunangst 10y agoDon't waste your time with the old crap. :)
- paulddraper 10y agoSure, but (a) it can handle the malloc failure and (b) it's pretty easy for the user to find the bad guy.
- deathanatos 10y agoIt might handle the malloc failure by crashing. Some languages (e.g., Rust) and runtimes (e.g., glib) presume that small allocations always succeed; a failure in such an allocation immediately crashes the program (as the underlying API provides no means to report the failure).
- steveklabnik 10y agoRust the language doesn't know anything about allocation; it's entirely a standard library decision.
- mikeash 10y ago(a) it probably won't therefore (b) the "bad guy" is going to be most/all processes.
- __s 10y agoThe OOM killer doesn't pick the process by an entirely random method, it seeks to kill the problem