Without knowing your precise requirements I'm not sure if this will help you. But you can take a look at SystemTap. It's a powerful dynamic tracing framework. Essentially you write stap scripts that turn on/off tracepoints and does some processing each time a tracepoint is hit.
There are already many memory related stap scripts available. If none of them do what you want it's likely that you can write an stap script of your own to meet your exact requirements.
Here's a list of publicly available memory related stap scripts: https://sourceware.org/systemtap/examples/keyword-index.html#MEMORY