How to clear variables and/or whole work space


hello ,i’m a newcomer. i use Atom as my IDE for julia . How to clear the information in REPL and the variables that i do not need in the work space


I don’t use Atom but in Julia 0.6 REPL, you can use the workspace() function to clear things up.

julia> a = 1

julia> a

julia> workspace()

julia> a
ERROR: UndefVarError: a not defined


Note that workspace is gone in 0.7, so going forward the only way to clear your workspace is to quit and restart Julia.


I think you can replace your variables with nothing and then garbage collect.

The following shows what I mean:



But then the binding still exists.


Is that harmful?


Depends on what you want, just saying it’s different from the behavior of workspace().


Using workspace() in Juno is a bad idea and will break all sorts of things, so I’d really advise against it.

You can clear the REPL display with Ctrl-J Ctrl-C or by typing clearconsole() into the REPL, however.


thank u all very much . i got it.


Ctrl+J, Ctrl+C will clear the Console but not the Workspace: the variables and functions created are not cleared.

You can clear the Workspace from the Console by pressing Ctrl+D to end Julia and Enter to start it again. This works reasonably fast.

I am working in Juno/JuliaPro. Is there any other method to clear the Workspace without stopping Julia?


There used to be a workspace() function, but it was removed as it had some problems. I think that the consensus is that stopping and restarting the process is now fast enough for practical purposes.


It is fast when the project doesn’t have many dependencies. But with more dependencies, it takes more time. Is there any method to restart without precompile again?