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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:41:57+00:00 2026-06-17T22:41:57+00:00

I run simulations on a Windows 64bit-computer with 64 GB RAM . Memory use

  • 0

I run simulations on a Windows 64bit-computer with 64 GB RAM. Memory use reaches 55% and after a finished simulation run I remove all objects in the working space by rm(list=ls()), followed by a gc().

I supposed that this would free enough memory for the next simulation run, but actually memory usage drops by just 1%. Consulting a lot of different fora I could not find a satisfactory explanation, only vague comments such as:

"Depending on your operating system, the freed up memory might not be returned to the operating system, but kept in the process space."

I’d like to find information on:

  1. which OS and under which conditions freed memory is not returned to the OS, and
  2. if there is any other remedy than closing R and start it again for the next simulation run?
  • 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-17T22:41:58+00:00Added an answer on June 17, 2026 at 10:41 pm

    How do you check memory usage? Normally virtual machine allocates some chunk of memory that it uses to store its data. Some of the allocated may be unused and marked as free. What GC does is discovering data that is not referenced from anywhere else and marking corresponding chunks of memory as unused, this does not mean that this memory is released to the OS. Still from the VM perspective there’s now more free memory that can be used for further computation.

    As others asked did you experience out of memory errors? If not then there’s nothing to worry about.

    EDIT:
    This and this should be enough to understand how memory allocation and garbage collection works in R.

    From the first document:

    Occasionally an attempt is made to release unused pages back to the
    operating system. When pages are released, a number of free nodes
    equal to R_MaxKeepFrac times the number of allocated nodes for each
    class is retained. Pages not needed to meet this requirement are
    released. An attempt to release pages is made every R_PageReleaseFreq level 1
    or level 2 collections.

    EDIT2:

    To see used memory try running gc() with verbose set to TRUE:

    gc(verbose=T)
    

    Here’s a result with an array of 10’000’000 integers in memory:

    Garbage collection 9 = 1+0+8 (level 2) ... 
    10.7 Mbytes of cons cells used (49%)
    40.6 Mbytes of vectors used (72%)
              used (Mb) gc trigger (Mb) max used (Mb)
    Ncells  198838 10.7     407500 21.8   350000 18.7
    Vcells 5311050 40.6    7421749 56.7  5311504 40.6
    

    And here’s after discarding reference to it:

    Garbage collection 10 = 1+0+9 (level 2) ... 
    10.7 Mbytes of cons cells used (49%)
    2.4 Mbytes of vectors used (5%)
             used (Mb) gc trigger (Mb) max used (Mb)
    Ncells 198821 10.7     407500 21.8   350000 18.7
    Vcells 310987  2.4    5937399 45.3  5311504 40.6
    

    As you can see memory used by Vcells fell from 40.6Mb to 2.4Mb.

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

Sidebar

Related Questions

We use employees' desktops for CPU-intensive simulation during the night. Desktops run Windows -
I'm trying to run an ATM Simulation in C# with Windows Forms that can
I'm trying to put together a model of a computer and run some simulations
Using Windows 7 + python 2.6, I am trying to run a simulation model
How to run local files on iphone? I use Windows 7 and i have
I'm using ghdl+gtkwave for studying, on Windows 7. I run simulations by calling some
In the course of vectorizing some simulation code, I've run into a memory issue.
I've run simulations which have given me data points corresponding to X number of
I'm not sure what the appropriate terminology is, but in trying to run simulations,
I need to run a MonteCarlo simulations in parallel on different machines. The code

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.