Reduce the memory consumption in the interpreter.

The unittest is mostly there for valgrind test purpose.