How expensive is it to dereference a pointer?

后端 未结 6 1549
攒了一身酷
攒了一身酷 2020-12-12 15:07

How expensive is it to perform the dereference operation on a pointer?

I can imagine that the memory transfer is somehow proportional to the object size, but I want

6条回答
  •  没有蜡笔的小新
    2020-12-12 15:36

    Dereferencing can be expensive mostly because it costs an instruction to fetch data from memory which might be far away and do not exhibit locality of reference. In that case, the processor should fetch data from non-cached memory and even hard disk (in case of a hard page fault).

提交回复
热议问题