On Tue, May 19, 2009 at 08:45:36AM +0200, Jim Meyering wrote:
> Fabio M. Di Nitto wrote:
> >> @@ -150,6 +162,10 @@ void corosync_request_shutdown (void)
> >> poll_stop (0);
> >> totempg_finalize ();
> >> coroipcs_ipc_exit ();
> >> +
> >> + /*Remove uidgid_list*/
> >> + corosync_remove_uidgid_list ();
> >
> > Is there really a need to free this list on exit? we are about to abort
> > anyway and the kernel will take care of that.
> >
> >> +
> >> corosync_exit_error (AIS_DONE_EXIT);
> >> }
>
> "need", maybe not.
> But it is generally good to explicitly free otherwise-leaked memory,
> even just before exit.
>
> The benefit comes when you use a tool like valgrind to find leaks.
> With the explicit free, no leak is reported here.
> If you remove the free, valgrind reports the leak
> and you or multiple people will have to go investigate it.
> Perhaps multiple times.
>
> This becomes especially relevant only once you have
> enough of a regression test suite to exercise such code paths.
It's even important just to understand what the code is doing.
There's nothing like hunting around for the free of an allocation and
never finding it.
Basically, if you want a particular allocation to be freed by
exit, you mark it such with a comment and never free it, even on a clean
exit. Otherwise, you try to clean up nicely even in exceptional
circumstances.
Joel
--
"Lately I've been talking in my sleep.
Can't imagine what I'd have to say.
Except my world will be right
When love comes back my way."
Joel Becker
Principal Software Developer
Oracle
E-mail: [email protected]
Phone: (650) 506-8127
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais