back ported --maxheapgb flag(and related changes) from 2.8.4_msopen branch