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 C_sprdist #92

Merged
merged 1 commit into from Jan 14, 2020
Merged

Memory leak in C_sprdist #92

merged 1 commit into from Jan 14, 2020

Conversation

ms609
Copy link
Contributor

@ms609 ms609 commented Jan 14, 2020

I am encountering a memory leak when I use SPR.dist to compare large numbers of trees. Over time, all my RAM is consumed.

set.seed(1)
for (i in 1:1000) {
  cat('.')
  trees <- lapply(rep(40, 50), ape::rtree, br = NULL)
  # If trees are not re-ordered, then path.dist often crashes
  trees <- structure(lapply(trees, TreeTools::Postorder), class='multiPhylo')
  phangorn::SPR.dist(trees)
}

From a very brief glance at the code, I notice that split->s_split seems to be malloced, but never freed; a possible fix to this issue is proposed. But it is probably worth taking a more careful and detailed look at the code than this to check that there are not additional leaks.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.007%) to 69.726% when pulling a1b1452 on ms609:patch-1 into a969c0e on KlausVigo:master.

Copy link

@leomrtns leomrtns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! And thanks for the fix

@KlausVigo KlausVigo merged commit b96c142 into KlausVigo:master Jan 14, 2020
@KlausVigo
Copy link
Owner

Thanks @ms609
for catching and fixing this.

@ms609 ms609 deleted the patch-1 branch January 14, 2020 13:53
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

Successfully merging this pull request may close these issues.

None yet

4 participants