Understanding and optimizing the statistical performance of machine learning models under memory budgets