Memory leak using rpy

I have a small part in my code that is similar to this one (for example, with real matrices instead of zero filled ones):

x = [rinterface.FloatSexpVector([0]*(1000**2)) for i in xrange(20)]
y = robjects.r('list')(x)

and it looks like it is causing a memory leak.

When running the following code:

for i in xrange(10):
    x = [rinterface.FloatSexpVector([0]*(1000**2)) for i in xrange(20)]
    y = robjects.r('list')(x)
    del x
    del y
    robjects.r('gc(verbose=TRUE)')

I get:

Error: cannot allocate vector of size 7.6 Mb
In addition: Warning messages:
1: Reached total allocation of 2047Mb: see help(memory.size)
2: Reached total allocation of 2047Mb: see help(memory.size)
3: Reached total allocation of 2047Mb: see help(memory.size)
4: Reached total allocation of 2047Mb: see help(memory.size)

Is this a mistake or is there something else I should do? I also tried making the named variable by placing it in robjects.globalenv and then rm () before them before gc (), but it does not seem to work.

I should mention that I run rpy 2.3dev on windows, but this also happens on linux with rpy 2.2.6 (although since linux runs 64-bit and not 32-bit, as a Windows computer does, the memory just grows and I do not get error 2047mb)

: , gc.collect() , R gc() , - , , , , .names, :

x = [rinterface.FloatSexpVector([0]*(1000**2)) for i in xrange(20)]
y = robjects.r('list')(x)[0]
y.names = rinterface.StrSexpVector(['a']*len(y))

rinterface.NULL . ?

+5
2

, , Python , R, , .

rpy2 SO

, - . bitbucket rpy2 , .

+2

, . :

python:

l = range(32 * 1024 * 1024)

, 128 . ( 7 )

( - 256 ); N = 128 * 1024 * 1024; . , , , . , .

, 1 ++ 1 (i7 8 , Windows 8 CentOS6 - -es). Java.

, , python . , rpy / , , ; ( 4 ).

0

All Articles