# Is it necessary to close MathLink connection?

I use WSTP (formerly known as MathLink) program LoopTools (here is the link with executables and source: http://www.feynarts.de/looptools/). To create connection within Mathematica, I use command

Install["LoopTools"]


Now, as we work, we frequently restart kernel, so all symbolic rules are forgotten by kernel, and we need to run Install again.

There is another command, Uninstall, which terminates the program. My question is: is it really necessary to close every connection?

I was unaware of any problems you may encounter. But then I suddenly found, that LoopTools processes remain active in process table after restarting kernel. So I did the following experiment:

1. Open Mathematica
2. Run Do[Install["LoopTools"],{10}]
3. Observe 10 processes in system monitor.
4. Quit Mathematica.
5. They are still there.

Is the problem in program I use (LoopTools) or in Mathematica? Or it is documented behavior, and I just should be aware of every connection I've opened?

Version: Mathematica 10.1.0.0 Linux x86 (64-bit)

P.S. I think there should be wstp tag (since it is how we call MathLink in 10 version), but I cannot create it with my profile stats.

Edit: It seems to be module-specific, e.g. addtwo example from documentation terminates itself automatically with kernel.

• It is not necessary to close the connection as long as it doesn't cause you any problems. But the fact that these processes (and their overhead in the MathLink library) persist otherwise suggests that you should do it. MathLink is not infinitely scalable and will run into problems with a surprisingly small number of processes (unless something changed dramatically for version 10). The process model is client-server. Just because you close the client (Mathematica), it doesn't mean the server process should necessarily go away. – Oleksandr R. May 20 '15 at 0:18