def used_memory(unit: int=1024 * 1024 * 1024) ->float:
    """Get the memory usage of the current process and all sub-processes.

    :param unit: unit of the memory, default in Gigabytes
    """
    try:
        import resource
        return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / unit
    except ModuleNotFoundError:
        from . import default_logger
        default_logger.error(
            'module "resource" can not be found and you are likely running it on Windows, i will return 0'
            )
        return 0
