Are you trying to implement it in the compiler or what? What you are referring to Metrics is somewhat related to Virtual Memory.