C ++ stack memory and processor cache

I heard that data pushed onto the C ++ stack most likely appears in the CPU cache.
http://www.gamedev.net/topic/564817-stack-and-cache-question-optimizing-sw-in-c/#entry4617168

"The stack is the most efficient place to store data because the same range of memory addresses is reused over and over."

Due to the implied order of operations, the most commonly used stack data is almost certainly always in the L1 cache.

It's true?


I mean, is it better to try to store frequently used data on the stack than on the heap?

+4
source share
1 answer

++ Standard - : , ..

, ++, ( ).

, . : L1 (32k?) , , L2. 64k ( , ), 0, 16k, 32k 48k : L2.

, , , . ( ).

, :

  • : , .
  • : , , ( Stack Smashing).
  • : ++ (RAII, SBRM), . "" - .

, , .

+3

Source: https://habr.com/ru/post/1541269/


All Articles