freeing device memory