Clearing variables in Jupyter Lab

I’m running a computation in Julia (specifically via Jupyter Lab) that uses up over half of my RAM, and I find if I do not clear my workspace before running it again by shutting down and then restarting the kernel my PC runs out of RAM and crashes. Shutting down and restarting the kernel is a little more tedious than running a command, so I’m hoping someone has a command I can run to clear the workspace instead of having to go through this whole rebooting the kernel process.

To clear the workspace I have tried running workspace() and that just returned UndefVarError: workspace not defined, and I have also tried running clearconsole() which likewise returned UndefVarError: clearconsole not defined.

You can free the memory that a variable x is taking up by running x = nothing. You would just have to find which variables are taking up the most memory and set them to nothing.

1 Like