make shmem swappable by ref and ptr
add static function to remove shared memory