Use the undocumented switch /S of the DOS command <SET to get the number of remaining free bytes in the DOS environment. Note that you do not need this option in OS/2 sessions because the size of the environment of OS/2 sessions is dynamic.
Source: The OS/2 WARP Survival Guide