old_contents: import os
  import sys
  import stat
  import subprocess
  import requests
  from xbmctorrent.common import BIN_PATH
  
  
  def ensure_exec_perms(file_):
      st = os.stat(file_)
      os.chmod(file_, st.st_mode | stat.S_IEXEC)
      return file_
  
  TORRENT2HTTP_BINARY = ensure_exec_perms(os.path.join(BIN_PATH, "torrent2http%s" % (sys.platform == "win32" and ".exe" or "")))
  
  def find_free_port():
      import socket
      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      s.bind(('', 0))
      port = s.getsockname()[1]
      s.close()
      return port
  
  def start(**kwargs):
      bind_address = "localhost:%d" % find_free_port()
      args = [TORRENT2HTTP_BINARY, "--bind", bind_address]
      for k, v in kwargs.items():
          args.append("--%s" % k)
          if v:
              args.append(v)
  
      # Needed because torrent2http is vendored with Boost and libtorrent-rasterbar
      env = os.environ.copy()
      env["LD_LIBRARY_PATH"] = BIN_PATH
      env["DYLD_LIBRARY_PATH"] = BIN_PATH
  
      import xbmc
      xbmc.log(repr(args))
      kwargs = {
          "cwd": BIN_PATH,
          "env": env,
      }
      if sys.platform == "win32":
          si = subprocess.STARTUPINFO()
          si.dwFlags |= 1
          si.wShowWindow = 0
          kwargs["startupinfo"] = si
      proc = subprocess.Popen(args, **kwargs)
      proc.get_bind_address = lambda: bind_address
      proc.shutdown = lambda: requests.post("http://%s/shutdown" % bind_address)
      return proc
  
new_contents: import os
  import sys
  import stat
  import subprocess
  import requests
  from xbmctorrent.common import BIN_PATH
  from xbmctorrent.platform import PLATFORM
  
  
  def ensure_exec_perms(file_):
      st = os.stat(file_)
      os.chmod(file_, st.st_mode | stat.S_IEXEC)
      return file_
  
  TORRENT2HTTP_BINARY = ensure_exec_perms(os.path.join(BIN_PATH, "torrent2http%s" % (sys.platform == "win32" and ".exe" or "")))
  
  def find_free_port():
      import socket
      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      s.bind(('', 0))
      port = s.getsockname()[1]
      s.close()
      return port
  
  def start(**kwargs):
      bind_address = "localhost:%d" % find_free_port()
      args = [TORRENT2HTTP_BINARY, "--bind", bind_address]
  
      # Are we on ARM? Activate minimum memory mode
      if PLATFORM["arch"] == "arm":
          kwargs["minmem"] = None
  
      for k, v in kwargs.items():
          args.append("--%s" % k)
          if v:
              args.append(v)
  
      # Needed because torrent2http is vendored with Boost and libtorrent-rasterbar
      env = os.environ.copy()
      env["LD_LIBRARY_PATH"] = BIN_PATH
      env["DYLD_LIBRARY_PATH"] = BIN_PATH
  
      import xbmc
      xbmc.log(repr(args))
      kwargs = {
          "cwd": BIN_PATH,
          "env": env,
      }
      if sys.platform == "win32":
          si = subprocess.STARTUPINFO()
          si.dwFlags |= 1
          si.wShowWindow = 0
          kwargs["startupinfo"] = si
      proc = subprocess.Popen(args, **kwargs)
      proc.get_bind_address = lambda: bind_address
      proc.shutdown = lambda: requests.post("http://%s/shutdown" % bind_address)
      return proc
  
subject: use minimum memory mode on ARM