Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6691313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:44:14+00:00 2026-05-26T05:44:14+00:00

When is the CPU Data Cache updated? Take these situations as examples: Example 1:

  • 0

When is the CPU Data Cache updated?
Take these situations as examples:

Example 1:

SomeObject* pObject; 
//[...]
pObject->member = variable;

Example 2:

SomeObject object; 
object.member = variable;

How is cache updated in those examples?
Is it the same? Or are there differences in terms of data access because example 1 uses a pointer and example 2 doesnt?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:44:15+00:00Added an answer on May 26, 2026 at 5:44 am

    In example 1, CPU first needs to access the pointer itself, then the actual object.

    • Pointer is on the stack which gives it a good chance it is already in data cache due good locality with other variables on the stack. It might even be in register.
    • It is unusual for the object to be on the same stack frame as pointer – it is either on the heap (on “random” location) or on a shallower stack frame, and there is a possibility it is no longer in d-cache so you are more likely to pay memory latency penalty.

    In example 2, CPU can access the object directly, which is on the stack so it has a good chance it is already cached due good locality with to other variables on the stack.

    All the memory locations accessed will end-up in d-cache until replaced by more recently accessed locations. How exactly is d-cache maintained and synchronized between different cores in multi-core CPU is implementation detail of a particular CPU and involves “cache lines” (typically 64-bit blocks that are “units” of caching) and various cache coherence protocols.

    That being said, you should be aware of a serious degradation of performance in multi-threaded environment that may be consequence of these implementation details, called false sharing.

    Generally speaking, chasing pointers is slower than just accessing memory linearly, because it has worse locality (so caches are less effective) and worse predictability (so CPU cannot utilize prefetching effectively).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to view historical data for guest cpu/memory/IO usage, rather than just current
I'd like to collect data of L2 cache misses for different cache associativity settings
Under WindowsCE, C++ project, I'd like to get CPU utilization and memory allocation data
I am interested in forcing a CPU cache flush in Windows (for benchmarking reasons,
I have an app that allows the user to cache data for offline use.
I'm a little confused by the meaning of Aliasing between CPU-cache and Physical address
I am building a cache that has to store as much data as possible.
Years ago I was learning about x86 assembler, CPU pipelining, cache misses, branch prediction,
CPU Switches from User mode to Kernel Mode : What exactly does it do?
Taking CPU affinity into account, will such an environment be useful with threading? Or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.