TheCatWhisperer
TheCatWhisperer

Reputation: 981

Actual number of bytes in CPU Cache from WMI

This question/answer shows how to get the cache size from the Windows Management Object

Let's say for MaxCacheSize, the number I get back is 512. The documentation says it returns kilobytes. Do they mean exactly 512,000 bytes, or should I extrapolate this to mean 524,288?

Upvotes: 0

Views: 123

Answers (1)

Jeroen Mostert
Jeroen Mostert

Reputation: 28789

In general, unless explicitly indicated otherwise, memory sizes use binary prefixes, so a kilobyte of memory (main or cache) is 1024 bytes, not 1000. The size of the cache is typically not the size of the memory chips used to implement the cache, but the amount of main memory the cache can cache, so it simply follows the policy of main memory addressing conventions. (The cache itself is physically bigger, due to bookkeeping overhead.)

Wikipedia has an extensive article on the history behind this convention and also notes "capacities of main memory and cache memory are usually expressed with customary binary prefixes".

By sheer coincidence, 512 000 bytes is precisely 500 KiB, a doubly round number. Even so, a MaxCacheSize value of "512 kilobytes" is certainly 524 288 bytes (512 KiB).

Upvotes: 1

Related Questions