<DIV>hello, please note the followed code:</DIV>
<DIV>////////// BasicTaskScheduler //////////</DIV>
<DIV>BasicTaskScheduler* BasicTaskScheduler::createNew() {<BR> return new BasicTaskScheduler();<BR>}</DIV>
<DIV>#define MAX_SCHEDULER_GRANULARITY 10000 // 10 microseconds: We will return to the event loop at least this often<BR>static void schedulerTickTask(void* clientData) {<BR>  ((BasicTaskScheduler*)clientData)->scheduleDelayedTask(MAX_SCHEDULER_GRANULARITY, schedulerTickTask, clientData);<BR>}</DIV>
<DIV>BasicTaskScheduler::BasicTaskScheduler()<BR>  : fMaxNumSockets(0) {<BR>  FD_ZERO(&fReadSet);<BR>  FD_ZERO(&fWriteSet);<BR>  FD_ZERO(&fExceptionSet);</DIV>
<DIV>  schedulerTickTask(this); // ensures that we handle events frequently<BR>}</DIV>
<DIV>BasicTaskScheduler::~BasicTaskScheduler() {<BR>}</DIV>
<DIV> </DIV>
<DIV>this code scheduled a task "schedulerTickTask" when construction, but not unscheduler it.</DIV>
<DIV>so, when the BasicTaskScheduler object destruct, it will be mem leak.</DIV>
<DIV> </DIV>
<DIV>class BasicTaskScheduler: public BasicTaskScheduler0 {<BR>public:<BR>  static BasicTaskScheduler* createNew();<BR>  virtual ~BasicTaskScheduler();</DIV>
<DIV>public:<BR>  void schedulerTickTask();</DIV>
<DIV>protected:<BR>  BasicTaskScheduler();<BR>      // called only by "createNew()"</DIV>
<DIV>protected:<BR>  // Redefined virtual functions:<BR>  virtual void SingleStep(unsigned maxDelayTime);</DIV>
<DIV>  virtual void setBackgroundHandling(int socketNum, int conditionSet, BackgroundHandlerProc* handlerProc, void* clientData);<BR>  virtual void moveSocketHandling(int oldSocketNum, int newSocketNum);</DIV>
<DIV>protected:<BR>  // To implement background operations:<BR>  int fMaxNumSockets;<BR>  fd_set fReadSet;<BR>  fd_set fWriteSet;<BR>  fd_set fExceptionSet;</DIV>
<DIV>  TaskToken fTickTask; // !!! THIS ONE !!!<BR>};</DIV>
<DIV></DIV>
<DIV>////////// BasicTaskScheduler //////////</DIV>
<DIV>BasicTaskScheduler* BasicTaskScheduler::createNew() {<BR> return new BasicTaskScheduler();<BR>}</DIV>
<DIV>#define MAX_SCHEDULER_GRANULARITY 10000 // 10 microseconds: We will return to the event loop at least this often<BR>static void schedulerTickTask(void* clientData) {<BR>  ((BasicTaskScheduler*)clientData)->schedulerTickTask();<BR>}</DIV>
<DIV>void BasicTaskScheduler::schedulerTickTask()<BR>{<BR>  fTickTask = scheduleDelayedTask(MAX_SCHEDULER_GRANULARITY, ::schedulerTickTask, this);<BR>}</DIV>
<DIV>BasicTaskScheduler::BasicTaskScheduler()<BR>  : fMaxNumSockets(0) {<BR>  FD_ZERO(&fReadSet);<BR>  FD_ZERO(&fWriteSet);<BR>  FD_ZERO(&fExceptionSet);<BR>  schedulerTickTask(); // ensures that we handle events frequently<BR>}</DIV>
<DIV>BasicTaskScheduler::~BasicTaskScheduler() {<BR>  unscheduleDelayedTask(fTickTask); fTickTask = NULL;<BR>}<BR></DIV>
<DIV>/////</DIV>
<DIV>thanks</DIV>
<DIV> </DIV>