\w [0|1|n]

With no parameter, returns current memory usage, as a list of 6 long integers.

0   number of bytes allocated
1   bytes available in heap
2   maximum heap size so far
3   limit on thread heap size, from -w command-line option
4   mapped bytes
5   physical memory
q)\w
168144 67108864 67108864 0 0 8589934592

\w 0 and \w 1 return a pair of longs:

0   number of internalized symbols
1   corresponding memory usage
q)\w 0
577 25436

The utility .Q.w formats all this information.

Run-time increase Since 2017.11.06, \w allows the workspace limit to be increased at run-time, if it was initialized via the -w command-line option. E.g. system "w 128" sets the -w limit to the larger of 128 MB and the current setting and returns it.

If the system tries to allocate more memory than allowed, it signals -w abort and terminates with exit code 1.

Specifying too large a number will fall back to the same behavior as \w 0 or \w 1.

q)\w
339168 67108864 67108864 104857600 0 8589934592
q)\w 0
651 28009
q)\w 128
134217728
q)\w 1000000000
1048576000000000
q)\w 1000000000000
651 28009

If the workspace limit has not been set by the command-line option -w, an error is signalled.

q)\w 3
'-w init via cmd line

Domain-local Since V4.0 2020.03.17 returns information for the current memory domain only.

q)value each ("\\d .m";"\\w";"\\d .";"\\w")
::
353968 67108864 67108864 0 0 8589934592
::
354032 67108864 67108864 0 0 8589934592