There is nothing much you can do after Julia triggers an OutOfMemory. If this happens inside a try–catch block, then there is some chance Julia will be able the capture it and (also depending on some luck) after you get out of the block the objects that caused the problem will be out of scope and have been freed already.
clean up the previous saved variable, but I don’t know how to do it
There is no simple way to just freeing a Julia object so I am not sure of what you tried. You can assign nothing to it and then call Base.GC.gc(true) but this will likely take some time and, in meantime, probably will allocate some memory.
I had a similar problem between function calls, within which I loaded a large dataset (requiring roughly 90% of RAM). Initially, I thought the garbage collector would automatically free memory once the function scope was left but this was not the case.
Manually triggering GC between function calls via GC.gc() helped in this case. The function evaluation would take hours so GC would not be a bottleneck. Otherwise, the equivalent approach by @Henrique_Becker (if you do not leave scope) should work.