import errno


def is_out_of_memory_error(exception):
    """Returns true iff exception is an instance of OSError and error code represents an out of memory error."""
    return isinstance(exception, OSError) and exception.errno == errno.ENOMEM