Use macro for memory hook