B
Barry Kelly
Peter said:A pointer dereference is not expensive. I just benchmarked it at only 16% more
total time, in a tight loop.
A pointer dereference could potentially take seconds, if the page being
pointed to has been paged out by the OS. The memory hierarchy, and costs
of virtual memory lookup if the page isn't in the TLB, are substantial.
Of course you don't see them in a tight loop because all the caches etc.
aren't missing in that case. But the costs are substantial when missed.
-- Barry