Sometimes you need to wait until some amount of memory becomes free / available to proceed in a bash script.
For such cases MemAvailable in /proc/meminfo can be parsed. The following function checks this against some passed value and also allows to specify a timeout: