utils (version 3.6.2)

memory.size: Report on Memory Allocation (on Windows)


On MS Windows,

memory.size() reports the current or maximum memory allocation of the malloc function used in this version of R.

memory.limit() reports or increases the limit in force on the total allocation.

On non-Windows platforms

these are stubs which report infinity (Inf) with a warning.


memory.size(max = FALSE)

memory.limit(size = NA)



logical. If TRUE the maximum amount of memory obtained from the OS is reported, if FALSE the amount currently in use, if NA the memory limit.


numeric. If NA report the memory limit, otherwise request a new limit, in Mb. Only values of up to 4095 are allowed on 32-bit R builds, but see ‘Details’.


A number: On Windows, size in Mb (1048576 bytes), rounded to 0.01 Mb for memory.size and rounded down for memory.limit. On other platforms: Inf always.


Command-line flag --max-mem-size sets the maximum value of obtainable memory (including a very small amount of housekeeping overhead). This cannot exceed 3Gb on 32-bit Windows, and most versions are limited to 2Gb. The minimum is currently 32Mb.

If 32-bit R is run on most 64-bit versions of Windows the maximum value of obtainable memory is just under 4Gb. For a 64-bit versions of R under 64-bit Windows the limit is currently 8Tb.

Memory limits can only be increased.

Environment variable R_MAX_MEM_SIZE provides another way to specify the initial limit.

See Also

Memory-limits for other limits.

On Windows: The rw-FAQ for more details and references.


Run this code
if(.Platform$OS.type == "windows") withAutoprint({
# }

Run the code above in your browser using DataCamp Workspace