<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _setup_cgroup_memory_limit(self, memlimit, cgroups, pid_to_kill):
 """Start memory-limit handler. @return None or the memory-limit handler for calling cancel() """

        if memlimit is not None:
            try:
                oomThread = oomhandler.KillProcessOnOomThread(
                    cgroups=cgroups, pid_to_kill=pid_to_kill,
                    callbackFn=self._set_termination_reason,
                    kill_process_fn=self._kill_process)
                oomThread.start()
                return oomThread
            except OSError as e:
                logging.critical("OSError %s during setup of OomEventListenerThread: %s.",
                                 e.errno, e.strerror)
        return None