EVOLUTION-MANAGER
Edit File: Memory-limits.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Memory Limits in R</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for Memory-limits {base}"><tr><td>Memory-limits {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Memory Limits in R</h2> <h3>Description</h3> <p><span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> holds objects it is using in virtual memory. This help file documents the current design limitations on large objects: these differ between 32-bit and 64-bit builds of <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span>. </p> <h3>Details</h3> <p>Currently <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> runs on 32- and 64-bit operating systems, and most 64-bit OSes (including Linux, Solaris, Windows and macOS) can run either 32- or 64-bit builds of <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span>. The memory limits depends mainly on the build, but for a 32-bit build of <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> on Windows they also depend on the underlying OS version. </p> <p><span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> holds all objects in virtual memory, and there are limits based on the amount of memory that can be used by all objects: </p> <ul> <li><p> There may be limits on the size of the heap and the number of cons cells allowed – see <code><a href="Memory.html">Memory</a></code> – but these are usually not imposed. </p> </li> <li><p> There is a limit on the (user) address space of a single process such as the <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> executable. This is system-specific, and can depend on the executable. </p> </li> <li><p> The environment may impose limitations on the resources available to a single process: Windows' versions of <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> do so directly. </p> </li></ul> <p>Error messages beginning <code>cannot allocate vector of size</code> indicate a failure to obtain memory, either because the size exceeded the address-space limit for a process or, more likely, because the system was unable to provide the memory. Note that on a 32-bit build there may well be enough free memory available, but not a large enough contiguous block of address space into which to map it. </p> <p>There are also limits on individual objects. The storage space cannot exceed the address limit, and if you try to exceed that limit, the error message begins <code>cannot allocate vector of length</code>. The number of bytes in a character string is limited to <i>2^31 - 1 ~ 2*10^9</i>, which is also the limit on each dimension of an array. </p> <h3>Unix</h3> <p>The address-space limit is system-specific: 32-bit OSes imposes a limit of no more than 4Gb: it is often 3Gb. Running 32-bit executables on a 64-bit OS will have similar limits: 64-bit executables will have an essentially infinite system-specific limit (e.g., 128Tb for Linux on x86_64 cpus). </p> <p>See the OS/shell's help on commands such as <code>limit</code> or <code>ulimit</code> for how to impose limitations on the resources available to a single process. For example a <code>bash</code> user could use </p> <pre>ulimit -t 600 -v 4000000 </pre> <p>whereas a <code>csh</code> user might use </p> <pre>limit cputime 10m limit vmemoryuse 4096m </pre> <p>to limit a process to 10 minutes of CPU time and (around) 4Gb of virtual memory. (There are other options to set the RAM in use, but they are not generally honoured.) </p> <h3>Windows</h3> <p>The address-space limit is 2Gb under 32-bit Windows unless the OS's default has been changed to allow more (up to 3Gb). See <a href="https://docs.microsoft.com/en-gb/windows/desktop/Memory/physical-address-extension">https://docs.microsoft.com/en-gb/windows/desktop/Memory/physical-address-extension</a> and <a href="https://docs.microsoft.com/en-gb/windows/desktop/Memory/4-gigabyte-tuning">https://docs.microsoft.com/en-gb/windows/desktop/Memory/4-gigabyte-tuning</a>. Under most 64-bit versions of Windows the limit for a 32-bit build of <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> is 4Gb: for the oldest ones it is 2Gb. The limit for a 64-bit build of <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> (imposed by the OS) is 8Tb. </p> <p>It is not normally possible to allocate as much as 2Gb to a single vector in a 32-bit build of <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> even on 64-bit Windows because of preallocations by Windows in the middle of the address space. </p> <p>Under Windows, <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> imposes limits on the total memory allocation available to a single session as the OS provides no way to do so: see <code><a href="../../utils/html/memory.size.html">memory.size</a></code> and <code><a href="../../utils/html/memory.size.html">memory.limit</a></code>. </p> <h3>See Also</h3> <p><code><a href="../../utils/html/object.size.html">object.size</a>(a)</code> for the (approximate) size of <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> object <code>a</code>. </p> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>