GC problem

First I run this kind of code:


Do something heavy work, which allocate 64GB or more memory allocation


Then, I go to relase the memory:


But it the program keeps runing, never stop. What is going on?

What do you mean by that? Do you mean your program doesn’t stop execution?

It’s hard to help without knowing what code you’re running or what exactly the problem is.

Yes, the program does not stop execution, it seems will be running forever, as you can see:


And the memory does not a reaction to the GC.gc():

You are in a notebook (jupyter?), why should the kernel stop?

I’m not sure about the code surrounding this, but the original distral object is still there, so why should it be gone?

Yes, I am in a notebook (Vscode). The kernel should not to stop (as it happening), but the excution cell (Number [7], GC.gc()) should stop, but it not.

Are you certain it doesn’t stop? GC.gc() only returns nothing after all. Your CPU usage also suggests that nothing is running, with only 6% being in use.

Yes, definit sure. I tried several times, and end of getting the same situation.

Do you have an example I could use to reproduce this on my end? I’m still not sure I understand exactly what you’re doing in the notebook.

1 Like

So are you saying that the cell is still running and blocking other execution? So if you for example try to run 1+1 in another cell after that, it would lock up an never run?

Or are you saying the cell finishes, but the gc call does not do what you expect?

1 Like

That is the situation.

I wonder if you are creating an infinite loop of finalizers somehow.

Proberbly not, when I just run distrall[1:14](pnl_func), everything is ok.

I suggest don’t do that. While GC.enable(false) is an option to use, it is (or can be, very) dangerous (I would rarely if ever use it, and then very carefully), especially with 64 GB allocated. I find it likely you ran out of memory (not sure what happens for you, on Linux it might kill some other process, on Windows it’s I think guaranteed not to happen).

Note, there’s this new option in Julia 1.9:

--heap-size-hint=<size>    Forces garbage collection if memory usage is higher than that value.

Ideally you shouldn’t have to mess with some non-default option, and I’m not sure, they may have changed the default for that option. Only for some unusual situations, such as performance tuning or real-time, you should need non-default.