add optimization flags for mem