I have always wondered how i can control what is cached into the memory.

I always thought it was not possible to do with c++ atleast.

Until one day when a person told me not to include lua scripts in c++ application because it "...is notorious for completely ruining your cache...".

That got me thinking , is there anyway in c++ or any other compiled language to control what your program caches in memory.Because if lua can modify my cache performance, then why can't I.

If so,

i. Is it Architecture dependent or OS dependent ?

ii. Can you access what is in the cache or what is cached?.

Just to be Clear i am talking about CPU cache.