-
Notifications
You must be signed in to change notification settings - Fork 71
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
Referring to tables in TableCollection leaks memory #2428
Comments
TODO: add some reproducible example here using mprof |
Let's mimic the memory leak we see in import msprime
import time
before = time.perf_counter()
ts = msprime.sim_ancestry(
10000,
sequence_length=1000000,
population_size=10_000,
recombination_rate=1e-8,
random_seed=1234,
)
ts = msprime.sim_mutations(ts, rate=1e-7, random_seed=1)
print(ts)
duration = time.perf_counter() - before
print(f"Simulation of {ts.num_trees} trees done after {duration:.2f} seconds")
for site in ts.sites():
# pos = ts.tables.sites.position
tables = ts.tables
if site.id >= 1000:
break First, just accessing As it should be |
It seems like there must be some circular references down in where we do the allocation of the Table instances. It's all quite complicated and twisty down there though, so I'm at a bit of a loss as to what's going on here. |
We've got a couple of these piling up. Relevant to tskit-dev/msprime#1946? |
Yep, that's probably the same thing, thanks @molpopgen |
Note: #2080 is relevant here, because we create a new instance of the high-level table class each time |
It seems this is partially at least because of how we're doing metadata decoding. If I run the code accessing Line 721 in c12c160
Usage goes down to a nice flat 60MiB. So it seems like we've created a circular reference of some sort by wrapping the row_class, and so we leak some memory every time we access one of the tables. |
Also simplify the class structure of Tables Closes tskit-dev#2428
Also simplify the class structure of Tables Closes tskit-dev#2428
Also simplify the class structure of Tables Closes tskit-dev#2428
Also simplify the class structure of Tables Closes tskit-dev#2428
See analysis in #2424 for details, and e.g., #2427.
The text was updated successfully, but these errors were encountered: