The heapsize is not set when running the upgradeTool.
The configuration master_java_heap exists which gets applied to the master process startup. When running upgradeTool, it is launched as if it were master, except the -env.sh file is never sourced: https://github.com/caskdata/cdap/blob/develop/cdap-master/conf/master-env.sh#L31, and therefore JAVA_HEAPMAX is never set
possible fix: just source master-env.sh here: https://github.com/caskdata/cm_csd/blob/develop/src/scripts/cdap-control.sh#L93
possible workaround: set MASTER_JAVA_HEAPMAX environment safety valve, or put in the global cdap_java_opts