Adding memory limit for the learning process