# MX\_SETMEMFLAGS
> [HTML Version](mx_setmemflags.htm)
**xcall MIAMEX, MX\_SETMEMFLAGS, idx, flags**
MX\_SETMEMFLAGS (MIAMEX 163) is used to change the flags for a memory module.
**Parameters**
_idx_ ([Num](num.htm.md)) \[in\]
should be set to 0 to reference the memory module for the currently running program or subroutine, or else it can specify the module previous located in a call to MX\_USRMAP.
_flags_ ([Num](num.htm.md)) \[in\]
are the new flags (overriding the previous ones). If you just want to turn on or off a particular flag but leave existing flags alone, you should first retrieve the existing flags using the MX\_USRMAP call.
**Comments**
If you want to use this call within an SBX to cause the SBX to be deleted from memory on exit (instead of being retained as part of the normal caching scheme), then set FLAGS = USRMEM\_INUSE. If you do not have that flag set, the module could be deleted by a subsequent memory operation even while the program is running, which would be bad.