Skip to content

Memory leak in _insert when using rank 0 input (Trac #572) #1170

Closed

Description

@numpy-gitbot

Original ticket http://projects.scipy.org/numpy/ticket/572 on 2007-08-24 by @cournape, assigned to unknown.

The function _insert has a memory leak, and this shows when using for example cdf functions of distributions classes in scipy.stats (see scipy #1074).

The fix is trivial: just call Py_DECREF on ainput in rank 0 case, as in general case (the attached patch avoids separate code path for memory cleaning instead).

Activity

  1. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    Attachment added by @cournape on 2007-08-24: insert.2.fix

  2. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    Milestone changed to 1.0.4 Release by @alberts on 2007-08-26

  3. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    @stefanv wrote on 2007-08-28

    David, I'd like to write a regression test, but I don't see the same behaviour. Currently, I have:

    import numpy as N
    from numpy.lib._compiled_base import _insert
    x = N.array(1)
    _insert(x,[True],1)
    

    Would you please send me a snippet that replicates the problem?

  4. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    @cournape wrote on 2007-09-05

    Well, the memory leak is obvious when looking at the code, since the function arr_insert create a new reference of avals in any case, and this is dereferenced for all cases but rank 0 input.

    Your example does not show any leak, indeed... Since the memory leak is obvious, I think we would better apply the patch anyway. I will try to get the test code I used to detect the leak in the first place.

  5. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    @cournape wrote on 2007-09-05

    Ok, the following code shows the problem:

    #!python
    from numpy.lib import place
    
    while 1:
        place(1, 1, 1)
    

    Running it a few seconds under massif basically shows a linear increase of memory in the while loop.

  6. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    @stefanv wrote on 2007-09-20

    Fixed by Travis in r4049. Added test in r4053.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions