Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to shut down engine on Windows 10? #166

Open
ronubi opened this issue Jan 27, 2020 · 4 comments
Open

How to shut down engine on Windows 10? #166

ronubi opened this issue Jan 27, 2020 · 4 comments

Comments

@ronubi
Copy link

ronubi commented Jan 27, 2020

I have tried several different methods to shut down the Matlab engine, before logging out of a Jupyter notebook running a Julia 1.3 kernel in Firefox on a Windows-10 box. (I never explicitly launch the engine, just use mat"" commands.) When I restart the notebook (and the Julia kernel), then import MATLAB.jl, my Matlab workspace variables and path from the previous session are all still there. And Windows TaskManager shows a MATLAB process running. Of course I can just use TaskManager to "End task" - but that seems rather indirect.

The only way I have found to shut down the engine within the notebook is to do

MATLAB.mat"quit"

which results in

MATLAB.MEngineError("invalid engine session (err = 1)")

followed by

MATLAB.close_default_msession()
MATLAB.restart_default_msession()

which crashes the Julia kernel. Sometimes the kernel restarts on its own, other times I need to use the menu Kernel->Restart.

Please advise.

@musm
Copy link
Collaborator

musm commented Jan 27, 2020

Have you tried MATLAB.close_default_msession() ? What's the error in that case? It works for me from a terminal, not sure why it wouldn't when run form Jupyter.

@ronubi
Copy link
Author

ronubi commented Jan 27, 2020

Calling close_default_msession() seems to work, but it doesn't accomplish anything. If I then call mat"whos", I still see all the variables I had in the previous session! The same thing happens if I also call restart_default_msession()! It's like these functions are no-ops.

@ronubi
Copy link
Author

ronubi commented Jan 27, 2020

I just tested MATLAB.jl in a simple Julia REPL session. Similarly, close_default_msession() seems to be a no-op. However, when I quit the REPL (Ctrl-D), it does shut down the engine (and the Windows Matlab process). So the problem is that logging out of the Jupyter notebook session and shutting down the server (Ctrl-C & 'Y' for Yes) is not sufficient to kill the Matlab engine/process. I guess I'll follow up my Jupyter-notebook shutdown sequence with TaskManager Processes -> right-click on Matlab -> End-task, unless someone has a better idea.

(FYI, I always start the REPL or the Jupyter notebook from bash [MinGw on Windows].)

@vxj9800
Copy link

vxj9800 commented Jan 21, 2022

I have recently started using Julia with the MATLAB package. I am having similar issues where the pointer to the MATLAB session in Julia is unusable when close(s) is executed in REPL. However, the MATLAB session is still active (visible in task manager and still using resources, mostly RAM) and doesn't close until REPL is closed. I am using this package to access a toolbox in MATLAB. The real issue for me is that the computation I do require large amount of memory. So, about 5GB of memory stays allocated to the MATLAB session. I would love to have a solution for this issue so that I can make better use of the memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants