Re: Any correlation between malloc return value and physical location?
On Monday 13 October 2003 05:05, Kirk Strauser wrote:
> Is there any relationship between the address returned by malloc(3) and the
> physical address of the block of RAM?
Very improbable. You might every once in a while get a return tht matches the
physical memory, but in a virtual memory architecture this isn't very likely.
> If a identical programs (same data, different files) are launched at the
> same time so that each copy in memory is identical, and they all call
> malloc(some_constant), do they all get the same return address from
> malloc() or do they get different answers?
For small allocations, they probably do. Every program gets a certain amount
of heap memory from which malloc gets some, so allocations called in the same
order and for the same sizes are getting allocated at the same relative heap
addresses. For larger allocations or on an already cluttered heap, this will
vary, so I wouldn't count on seeing any reproduceable numbers.