Thanks for the suggestion about valgrind. Can someone please let me first understand the expected behaviour for memory usage.
Let's say when I first starts Julia REPL it takes 5% of RAM (according to top). Then I include "myfile.jl" and run myfunction(). During the execution of myfunction(), memory allocation of Julia reaches 40% of RAM (again according to top). Say running myfunction() involves no allocation of global objects - all object used are local. Then when myfunction() finished and I am at the REPL prompt, should top show the memory usage of Julia drops down to the previous level (5% of RAM)? My current observation is that it doesn't. Is this the expected behaviour?