Skip to content

Memory leak in astropy.table due to circular reference #7447

Closed

Description

@astrofrog

The following code illustrates a memory leak:

import numpy as np
from astropy.table import Column, Table


for iter in range(1000):
    c = Column(data=np.array([1, 2, 3]))
    t = Table([c])

c = t = None

import objgraph
objgraph.show_backrefs(objgraph.by_type('Column'))

The resulting graph shows 48 Column objects that all look like:

refs

The issue is that Column.info._parent points to the Column object itself. We should use a weak reference to avoid this. I believe this is the root cause of #7440 so this shows that the bug has real-life impact.

Activity

  1. astrofrog commented on May 10, 2018

    @astrofrog
    MemberAuthor

    This was originally fixed in #6277 then reverted in #6342 and is technically a duplicate of #6276. I'd rather leave this open for now for more visibility.

  2. astrofrog commented on May 10, 2018

    @astrofrog
    MemberAuthor

    @taldcroft - I wonder if we should try and open a PR for #6277 again to see if we still get failures. It looks like after we had reverted it I then commented that the failures had started appearing before #6277 was merged: #6291 (comment)

    So maybe it wasn't due to that. Could you open a PR with #6277 and we can try and restart the CI a large number of times to see if we ever get a failure?

  3. pllim commented on May 10, 2018

    @pllim
    Member

    @astrofrog @taldcroft -- I revived it in #7448 . FYI. Feel free to push to that branch as needed using your maintainer superpower.

  4. bsipocz commented on May 10, 2018

    @bsipocz
    Member

    So maybe it wasn't due to that. Could you open a PR with #6277 and we can try and restart the CI a large number of times to see if we ever get a failure?

    What about merging it in if it passes, but then keep an eye on possible travis failures? I don't think we can restart it enough times to trigger it with high confidence (at least previously similar attempts of mine were not very successful).

  5. saimn commented on Jun 5, 2018

    @saimn
    Contributor

    So, I guess this is fixed by #7448 ? (At least with @astrofrog 's example above I get no leaked references ! :))

  6. bsipocz commented on Jun 5, 2018

    @bsipocz
    Member

    We're still keeping an eye on that, but since it's merged I think we should close this, too. (And revisit if it comes back again).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions