Ressources management

When in a thread I use ConnectAttach() function and then, when the thread
ends, should I use ConnectDetach() function call ? If not, does the system
“see” what is going on and free the apropriate resources ?

On the same topic, if in a main() function I used ChannelCreate() do I have
to make a call to ChannelDestroy() before the main() ends? What happen if
not ?

The point is that I’m wondering what is going on if my program stops
prematurally and if it has no chance to release thes kind of ressources
correctly.

Thanks for your support, Philippe

Philippe BAUCOUR <philippe.baucour@ni.com> wrote:

When in a thread I use ConnectAttach() function and then, when the thread
ends, should I use ConnectDetach() function call ? If not, does the system
“see” what is going on and free the apropriate resources ?

You should call the detach routine, not just for resource reclaiming resons, but
to also to allow other threads to recover from the situation. When you attempt
to detach on a connection that has other threads blocked on it (MsgSendv) the
send will fail and return with an error.

On the same topic, if in a main() function I used ChannelCreate() do I have
to make a call to ChannelDestroy() before the main() ends? What happen if
not ?

When you exit main, the process gets cleaned up. Things like shared objects
etc, that have persistance/existance outside of a process will require you to
clean them up.

-Adam