def get_memory_usage(pid=None,timeout=1):
    '''get_memory_usage returns a dictionary of resident set size (rss) and virtual
    memory size (vms) for a process of interest, for as long as the process is running
    :param pid: the pid to use:
    :param timeout: the timeout
    :: notes
  
      example: 
 
          sleep 3 & exec python -m memory "$!"
    '''
    rss = []
    vms = []
    # If no pid is provided, look for environment variable
    pid = get_pid(pid)
    process = psutil.Process(pid)
    # Create lists of memory usage over time
    print(process.status())
    while process.status() == 'running':
        mem = process.memory_info()
        rss.append(mem.rss)
        vms.append(mem.vms)
        time.sleep(timeout)
    # http://pythonhosted.org/psutil/#psutil.Process.memory_info
    result = {"rss":rss,"vms":vms}
    print(result)
get_memory_usage returns a dictionary of resident set size (rss) and virtual
    memory size (vms) for a process of interest, for as long as the process is running
    :param pid: the pid to use:
    :param timeout: the timeout
    :: notes
  
      example: 
 
          sleep 3 & exec python -m memory "$!"