share memory code