2 ms·
Well, you never have guarantees that this won't happen even if you free(). Reasonable resource consumption is an engineering decision based on context (target,
by xyzzy123 13y ago
Well, you never have guarantees that this won't happen even if you free().
Reasonable resource consumption is an engineering decision based on context (target, expected problem size, etc).
Deliberate leaking is IMHO a totally viable engineering strategy. If anything, behaviour is actually more reliable and predictable than the alternatives apart from "upfront static allocation".
If you ran into problems and want the entire system to behave predictably, you could on Linux disable vm overcommit, set oom_adj (so leaker proc gets killed preferentially), set strict ulimits and ensure abort() on malloc failure. However if you have to go to these lengths, leaking might not be appropriate ;)