Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in Base - combining Tasks with eval #50363

Closed
schlichtanders opened this issue Jun 30, 2023 · 4 comments
Closed

Memory leak in Base - combining Tasks with eval #50363

schlichtanders opened this issue Jun 30, 2023 · 4 comments

Comments

@schlichtanders
Copy link

schlichtanders commented Jun 30, 2023

Hi there

First time I am trying to use Julia for infinite jobs (streaming). It is horrible I have to admit unfortunately. Lost 1 full week to track down memory leaks. Here another one:

for _ in 1:50
    @eval fetch(schedule(Task(() -> ())))
    GC.gc(true); GC.gc(false)
    Core.println(Base.gc_live_bytes() / 2^20)
end

running this will output something like

1.36197
1.36372
1.36546
1.36721
1.36896
1.3707
1.37245
1.3742
1.37595
1.37769
1.37944
1.38119
1.38293
1.38468
1.38643
1.38818
1.38992
1.39167
@KristofferC
Copy link
Sponsor Member

Aren't you generating infinite amount of code here with generating new closures?

For example, something like


const clos = () -> ()
for _ in 1:50
    @eval fetch(schedule(Task(clos)))
    GC.gc(true); GC.gc(false)
    Core.println(Base.gc_live_bytes() / 2^20)
end

seems to be stable.

Probably, dup of #14495

@schlichtanders
Copy link
Author

indeed, I may create new closures repeatedly (this is running as part of Pluto.jl).

if a closure is not cleaned up automatically when nothing references it, how can it be deleted manually?

@schlichtanders
Copy link
Author

schlichtanders commented Jun 30, 2023

I tried naming the inner function but this also does not work

for _ in 1:50
    @eval function myfunc() end
    GC.gc(true); GC.gc(false)
    Core.println(Base.gc_live_bytes() / 2^20)
end
...
4.07169
4.07333
4.07497
4.07661
4.07825
4.07989
4.08153
4.08317

@schlichtanders
Copy link
Author

Realized this is a complete duplicate 😄

The original issue already creates a named function and still experiences these problems.
The Task wrapper is not really needed, but yeah, it is a common context where this occurs.

I guess the greatest value I can add is to mention that this memory bug also happens when using Pluto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants