Added optional memory estimation.