# Memory management

The RAM management of Flux is complex as we must set and fixed the next three environment variables before running the software:
• JVM_MEMORY, the Java memory (in Mbytes)
• MEMSIZC3, the character memory (in Bytes)
• MEMSIZN3, the numerical memory (in Bytes)

and leave enough free memory for the linear solver (MUMPS).

For a batch use of Flux, the two first environment variables can be easily set to a fixed value for any project as:

export JVM_MEMORY=100        # In MBytes
export MEMSIZC3=52428800     # In Bytes

For an interactive use, these values are application and problem-dependent, so please refer to the document: How to launch Flux via command line

Using a batch scheduler, you provide the maximum amount of memory you want to allocate for a job. Instead of asking you to provide three different values for each Flux variables, you can use the previous values and deduce the last one. Supposing the maximum memory is given by the variable MEM in GigaBytes, the numerical memory can be set as:

# Set the ratio of the memory Altair Flux can use (as a division of two integers).
RATIO="4 / 10" # Altair Flux master has 40% of the memory, leaving 60% of MEM to MUMPS
# Deduce the numerical memory (in Bytes)
export MEMSIZN3=$((($MEM*1024*1024*1024*$RATIO)-$MEMSIZC3-($JVM_MEMORY*1024*1024))) echo Numerical Memory is of awk '{print$1/1024/1024/1024}' <<<\$MEMSIZN3 GB

If the batch scheduler used is PBS (Pro), if you use Computer Manager to submit jobs, MEM can be provided via the environment variable PAS_MEMORY for example. If you go through qsub requests, the easiest way to specify the memory is to add the variable MEM to the command as:

qsub [args] -v MEM=32 FluxPBSScript.pbs

which fixes the maximal memory to 32 GB. This mechanic should be easily portable to other batch schedulers.