Change exponential search in memory assignment

Stop expenential search when no more memory is given away (usualy at 1, 2 or 4),
since setting hi to inf caused, invalid memory assignment in actual cases