My script is working but why do I get this msg?

Hi,
I have a script to determine the max memory to set a worker to start up at. The variable will need to end up being "-Xmx512m" or "-Xmx256m" or "-Xmx768m."
Everything works fine BUT when I set the "MEMORY" variable I get the "Cmmand not foundine 40: -Xmx512m" msg though the variable is the correct value and it starts up fine. Why do I get this message? Does it have something to do with "-" or "x"?

Script below:
maxMemSize=`grep '^'$branchCode $MEMORY_SIZE_DIR/LoaderMemoryAndUploadFileSize.properties | cut -d= -f 2`;
MEMORY= -Xmx$maxMemSize

MEMORY= -Xmx$maxMemSize

Did you enter this as is ?

1) You shouldn't have space after = sign
2) You should use quote

yes, I will make changes thanks

---------- Post updated at 12:56 PM ---------- Previous update was at 12:50 PM ----------

hmm, strange
So if I do this
MEMORY= '-Xmx'$maxMemSize
my worker starts up correctly but I get the error msg listed above.
if I do this
MEMORY='-Xmx'$maxMemSize or MEMORY=-Xmx$maxMemSize
I dont get the error msg and the worker doesnt start up...ideas?

my line to startup a worker is below(if it helps)
nohup $JAVA_HOME/bin/java -DappName=IPLoader -Xms128m $MEMORY -Duser.timezone=GMT -verbose:gc -cp $IPWORKER_CLASSPATH:$IPWORKER_HOME:$CLASSPATH Loader $LOADER_DIR >> $logfile 2>&1 &

What gives

MEMORY="-Xmx$maxMemSize"

?

also try..
MEMORY="-Xmx${maxMemSize}"

it gives the memory setting like "Xmx765m" or something similair