It's perfectly possible for a given malloc
implementation to be deterministic in response (generally when talking about whether an implementation of malloc
is or isn't "deterministic" it's in terms of time taken that people care, as in whether it could be used in RT programming). It would depend on the virtual memory system in use, the code itself, and how deterministic the question of calls to it or an underlying memory manager by other code in the same process space was, but given the right conditions for all of those, you can have a deterministic malloc
.
All that said though, there's no reason why it should be. After all, any code that was depending on particular addresses being used could just ignore malloc
and write the the memory directly - it knows it's free to use, after all!
As such, since there's zero value in maintaining such deterministic behaviour, if it does happen it's purely an accident of several different implementation choices, and while they would be a bit interesting (it would be interesting to know just how such an implementation ended up being deterministic) they certainly aren't what one would expect.