add memory management for v3.0