  Quantum memory management is becoming a pressing problem, especially given
the recent research effort to develop new and more complex quantum algorithms.
The only existing automatic method for quantum states clean-up relies on the
availability of many extra resources. In this work, we propose an automatic
tool for quantum memory management. We show how this problem exactly matches
the reversible pebbling game. Based on that, we develop a SAT-based algorithm
that returns a valid clean-up strategy, taking the limitations of the quantum
hardware into account. The developed tool empowers the designer with the
flexibility required to explore the trade-off between memory resources and
number of operations. We present three show-cases to prove the validity of our
approach. First, we apply the algorithm to straight-line programs, widely used
in cryptographic applications. Second, we perform a comparison with the
existing approach, showing an average improvement of 52.77%. Finally, we show
the advantage of using the tool when synthesizing a quantum circuit on a
constrained near-term quantum device.
