Hook manual memory management