This is implementation dependent although I think it is probably safe to assume that the underlying system has a method to store the size of the allocated block.
The are at least 2 different methods I can think of of doing this which probably means there are many more that I haven't thought of.
Comment