code: def memory():
      
  
      mem_info = {}
  
      if platform.linux_distribution()[0]:
          with open('/proc/meminfo') as file:
              c = 0
              for line in file:
                  lst = line.split()
                  if str(lst[0]) == 'MemTotal:':
                      mem_info['total'] = int(lst[1])
                  elif str(lst[0]) in ('MemFree:', 'Buffers:', 'Cached:'):
                      c += int(lst[1])
              mem_info['free'] = c
              mem_info['used'] = (mem_info['total']) - c
      elif platform.mac_ver()[0]:
          ps = subprocess.Popen(['ps', '-caxm', '-orss,comm'], stdout=subprocess.PIPE).communicate()[0]
          vm = subprocess.Popen(['vm_stat'], stdout=subprocess.PIPE).communicate()[0]
  
          # Iterate processes
          process_lines = ps.split('\n')
          sep = re.compile('[\s]+')
          rss_total = 0  # kB
          for row in range(1, len(process_lines)):
              row_text = process_lines[row].strip()
              row_elements = sep.split(row_text)
              try:
                  rss = float(row_elements[0]) * 1024
              except:
                  rss = 0  # ignore...
              rss_total += rss
  
          # Process vm_stat
          vm_lines = vm.split('\n')
          sep = re.compile(':[\s]+')
          vm_stats = {}
          for row in range(1, len(vm_lines) - 2):
              row_text = vm_lines[row].strip()
              row_elements = sep.split(row_text)
              vm_stats[(row_elements[0])] = int(row_elements[1].strip('\.')) * 4096
  
          mem_info['total'] = rss_total
          mem_info['used'] = vm_stats["Pages active"]
          mem_info['free'] = vm_stats["Pages free"]
      else:
          raise('Unsupported Operating System.\n')
          exit(1)
  
      return mem_info
docs: Determine the machine's memory specifications.
  
      Returns
      -------
      mem_info : dictonary
          Holds the current values for the total, free and used memory of the system.