C++ memmgr: use shared_ptr
Merge branch 'cpp-refcnt' into cpp-fix