memory leak after using .names attribute

Issue #97 resolved
Former user created an issue

The following code seems to produce a memory leak: {{{ #!python x = [rinterface.FloatSexpVector([0](10002)) for i in xrange(20)] y = robjects.r('list')(x)[0] y.names = rinterface.StrSexpVector(['a']len(y))


It seems that invoking the R and python garbage collectors does not release the memory after deleting the objects if-and-only-if the assignment to the "names" attribute is used.

edit: format the code

Comments (6)

  1. Laurent Gautier

    This is almost certainly caused by an imbalance in "preserving"/"releasing" underlying R objects from R's garbage collection occurring when assigning a new "names". I am little busy, so the follow-up is slower than I wish, but this bug report is the opportunity to make changes I had on the back of my mind regarding "preserving"/"releasing" (e.g., 72130c7eb56e )

  2. Laurent Gautier

    Seems to be fixed with commit 1740:6874cf4bdefa.

    The following code see memory usage come down after garbage collection.

    from rpy2 import rinterface
    from rpy2 import robjects
    import gc
    x = [rinterface.FloatSexpVector([0]*(1000**2)) for i in xrange(20)]
    y = robjects.r('list')(x)[0]
    y.names = rinterface.StrSexpVector(['a']*len(y))
    del(x, y)
    r_gc = robjects.baseenv['gc']
  3. Log in to comment