The match with the “max memory of the master node” may be a coincidence, and depend on job type.
What was the job type, and what is “max memory of the master node”.
Custom values set for certain reserved variables, like ram_gb, will not be effective: