Added support for limiting memory usage.