def get_peak_mem():
    '''
    this returns peak memory use since process starts till the moment its called
    '''
    import resource
    rusage_denom = 1024.
    if sys.platform == 'darwin':
        # ... it seems that in OSX the output is different units ...
        rusage_denom = rusage_denom * rusage_denom
    mem = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / rusage_denom
    return mem
this returns peak memory use since process starts till the moment its called