Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8480159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:13:15+00:00 2026-06-10T19:13:15+00:00

I have a small part in my code thats similar to this one (ofcourse

  • 0

I have a small part in my code thats similar to this one (ofcourse with real matrices instead of the zero filled ones):

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

and it looks like its causing memory leaks.

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 bug or is there something else I should do? I’ve also tried making the variable named by putting them into robjects.globalenv and then rm()-ing them before the gc() but it doesnt seem to work.

I should mention that I’m running rpy 2.3dev on windows but this happens also on linux with rpy 2.2.6 (though since the linux runs 64 bit versions and not 32 bit like the windows machine does, the memory just grows and I dont get the 2047mb error)

EDIT:
It seems like adding gc.collect() before the R gc() resolves the issue with the first code example, however this didnt solve my problem – digging deeper into my code I found that the line that causes the problem is with assigning a value into .names, similar to this:

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

putting rinterface.NULL before cleaning doesn’t help either.
any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:13:16+00:00Added an answer on June 10, 2026 at 7:13 pm

    It might be because Python is unaware of the amount of memory allocated by the embedded R, and therefore does not know that garbage should be collectected.

    There is a bit about memory usage in the documentation for rpy2, and an earlier question on SO

    Your edit suggests there might be something going on. The best is to file a bug report on the bitbucket page for rpy2 and continue troubleshooting there rather than here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some code in which a small part of the code takes
I have four text boxes all with similar code. Each one on hover fades
my website for the most part works well, but I have one small problem
I have this small code library that I'm considering releasing into Open Source. I
I have a requirement to change a very small part of the WPF ComboBox's
I have a small section of php in one of my pages that isn't
I have a table generated from some PHP code that lists a SMALL amount
I'm looking for a better way to this. I have a chunk of code
It never happened to me. In Visual Studio, I have a part of code
I have some Java code that I 'inherited' from a previous co-worker. Part of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.