public function cleanup()
    {
        if (!$this->memory) {
            throw new \LogicException("Cleanup should be used after allocate.");
        }

        $this->memory->delete();
        $this->memory = null;
    }