Java and Prolog have quite different memory management policies. In
Java, memory is reclaimed when the garbage collector can determine
that no code will ever use the object occupying the memory. In Prolog,
the garbage collector additionally reclaims memory upon failure
(such as the failure implied in the use of
SPQuery::nextSolution()). This mismatch in the notion of memory
lifetime can occasionally cause problems.