def getFreeMem(self, pUnit=MEGABYTES):
        """
        | Starts a shell process to retrieve amount of free memory on the worker's system.
        | The amount of memory is transmitted in MEGABYTES, but can be specified to another unit
        | To estimate this, we retrieve specific values in /proc/meminfo:
        | Result = MemFree + Buffers + Cached

        :param pUnit: An integer representing the unit to which the value is converted (DEFAULT is MEGABYTES).
        :return: An integer representing the amount of FREE memory on the system
        :raise: OSError if subprocess fails. Returns "-1" if no correct value can be retrieved.
        """

        try:
            freeMemStr = subprocess.Popen(["awk",
                                           "/MemFree|Buffers|^Cached/ {free+=$2} END {print  free}",
                                           "/proc/meminfo"], stdout=PIPE).communicate()[0]
        except OSError, e:
            LOGGER.warning("Error when retrievieng free memory: %r", e)

        if freeMemStr == '':
            return -1

        freeMem = int(freeMemStr)

        if pUnit is MEGABYTES:
            freeMem = int(freeMem / 1024)
        elif pUnit is GIGABYTES:
            freeMem = int(freeMem / (1024 * 1024))

        return freeMem
dataset/ETHPy150Open mikrosimage/OpenRenderManagement/src/octopus/worker/worker.py/Worker.getFreeMem/original