In trying to create a reduced test case I figured out the source of my memory leak. It wasn't caused by Julia but by an external library I was calling (Sundials.jl). Pulling the dev version of Sundials.jl fixed the issue for me.
K Leo, if you are using any external library, that may be the cause of the memory leak you are seeing. -Luke On Wednesday, September 21, 2016 at 5:52:23 PM UTC-7, Yichao Yu wrote: > > On Wed, Sep 21, 2016 at 8:50 PM, Yichao Yu <yyc...@gmail.com <javascript:>> > wrote: > > On Mon, Sep 19, 2016 at 9:14 PM, Luke Stagner <lstag...@gmail.com > <javascript:>> wrote: > >> I actually ran into this issue too. I have a routine that calculates > fast > >> ion orbits that uses a lot of memory (90%). Here is the code (sorry its > not > >> very clean). I tried to run the function `make_distribution_file` in a > loop > >> in julia but it never released the memory between calls. I tried > inserting > >> `gc()` manually but that didn't do anything either. > > > > I don't have time currently but I'll try to reproduce it in a few days. > > What's your versioninfo() and how did you install julia? > > In the mean time, I would also appreciate if you can reduce it a > little, especially if you can remove some of the external > dependencies. > > > > >> > >> -Luke > >> > >> > >> On Monday, September 19, 2016 at 3:08:52 PM UTC-7, K leo wrote: > >>> > >>> The only package used (at the global level) is DataFrames. Does that > not > >>> release memory? > >>> > >>> On Tuesday, September 20, 2016 at 6:05:58 AM UTC+8, K leo wrote: > >>>> > >>>> No. After myfunction() finished and I am at the REPL prompt, top > shows > >>>> Julia taking 49%. And after I did gc(), it shows Julia taking 48%. > >>>> > >>>> On Tuesday, September 20, 2016 at 4:05:56 AM UTC+8, Randy Zwitch > wrote: > >>>>> > >>>>> Does the problem go away if you run gc()? > >>>>> > >>>>> > >>>>> > >>>>> On Monday, September 19, 2016 at 3:55:14 PM UTC-4, K leo wrote: > >>>>>> > >>>>>> 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? > >>>>>> > >> >