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 9265201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:00:40+00:00 2026-06-18T14:00:40+00:00

Suppose I have a value that is large in memory (perhaps a huge matrix).

  • 0

Suppose I have a value that is large in memory (perhaps a huge matrix). Is there a way to move that value to a different environment instead of copy then delete? The copy/clone approach temporarily increases the memory footprint by the size of the value.

I reviewed this post but it doesn’t contain the solution to my problem. Sharing the same environment (to avoid the copy) is not an option. I really do need to move the value.

  • 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-18T14:00:42+00:00Added an answer on June 18, 2026 at 2:00 pm

    Perhaps write to disk, delete, read from disk? The only potential problem I can foresee with this approach is that any relationships between parent/child environments will be lost. But if you’re simply trying to copy the values from one environment to another, maybe this isn’t a problem?

    Update:

    I cannot replicate what you say about the copy approach. The code below shows that the maximum memory used (as reported by gc) does not increase. This is because the values are “promised”, not deep-copied. A copy will be made, however, if you change an object in the new environment before you delete it from the old environment.

    R> e1 <- new.env()
    R> e1$x <- numeric(5e7)
    R> e1$y <- numeric(5e7)
    R> gc()
                used  (Mb) gc trigger  (Mb)  max used  (Mb)
    Ncells    171022   9.2     350000  18.7    350000  18.7
    Vcells 100271746 765.1  110886821 846.0 100272535 765.1
    R> e2 <- new.env()
    R> for(n in ls(e1, all.names=TRUE))
    +   assign(n, get(n, e1), e2)
    R> gc()
                used  (Mb) gc trigger  (Mb)  max used  (Mb)
    Ncells    171038   9.2     350000  18.7    350000  18.7
    Vcells 100271788 765.1  116511162 889.0 100272535 765.1
    R> identical(e1$x,e2$x)
    [1] TRUE
    R> identical(e1$y,e2$y)
    [1] TRUE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose that you have a large collection of key/value pairs, where the value is
Suppose I have a function that will return a large data structure, with the
Suppose we have a query that orders by a calculated value that is not
I have a small program that's supposed to sample some value from a device
I have the following operator< that is supposed to sort first by a value,
Suppose I have a XmlNode and I want to get the value of an
Suppose I have this annotation @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Name { String value(); }
suppose i have the following: boost::unordered_map< string , someValueType > map; someValueType& value =
Suppose I have 3 radio buttons with different values for each radio button and
Suppose I have a small database represented in memory as a DataTable, what is

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.