Custom data type with a time watcher and memory control at process exit.

Marc Lehmann schmorp at schmorp.de
Thu Oct 21 17:51:30 CEST 2010


On Thu, Oct 21, 2010 at 05:13:46PM +0300, vvvua <vvvua at lost.in.ua> wrote:
> >>I have to cancel watchers, destroy the loop and free memory.
> >If the process itself is shutting down (exiting?) then freeing the
> >watchers is just wasting cpu cycles, the OS does it for you, and much
> >faster.
> I know that but parent process isn't OS.

Yes, the parent process will not clean up for you, but the OS will do,
regardless of your parent process or not.

> So the right way is:
> 1) To store list of pointers to watchers.
> 2) When the callback rises, delete the pointer from the list and
> free memory.
> 3) At the end of the process free memory with help of list.

You can do that, but really, the OS will do it for you much faster. Big
promise :)

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list