3 ms·
I think that would ultimately have undesirable consequences. If this were an option on a malloc call, any such call would have to reserve the allocated memory
by mannykannot 7y ago
I think that would ultimately have undesirable consequences.
If this were an option on a malloc call, any such call would have to reserve the allocated memory at that point, reducing the usefulness of overcommit for other processes. This would set up a 'tragedy of the commons' scenario, where every application developer defensively uses this feature because other applications are using it.
- dooglius 7y agoIt's already quite easy to implement manually though, just do a write after allocation.
- mannykannot 7y agoThat's a good point, though I think one would have to write to each of the pages allocated to reserve the full extent of the memory allocated by the malloc call.
- twic 7y agoYou could mitigate that by treating these allocations conservatively: they only succeed if they can reserve the memory they want and there is 'enough' uncommitted memory left to cover all as-yet-uncommitted normal allocations. So, it would fail long before a normal allocation would. I don't know quite what 'enough' means, but this whole business is already a rat's nest of heuristics, so one more should fit in nicely.