## 7 Advanced

### 7.1 Memory

A good start when programming efficient is to have knowledge about how much memory different datatypes and operations require. It is implementation dependent how much memory the Erlang data types and other items consume, but here are some figures for the current erts-5.x beam system. The unit of measurement is memory words and as the current implementation is a 32-bit implementation a word is 32 bits.

Memory size of different datatypes
Datatype | Memory size
Integer (-16#7FFFFFF < i <16#7FFFFFF) | 1 word
Integer (big numbers) | 2..N words
Atom | 1 word
Float | 3 words
Binary | 2..5 + data
List | 2 words per element + the size of each element
String (is the same as a List of Integers) | 2 words per character
n-Tuple | (n + 1) words + the size of each element - 1
Pid | 1 word
Port | 1 word
Reference | 5 words
Fun | 6 + environment
Ets table | initially 768 words + the size of each data record. The table will grow when necessary.
Erlang process | 318 words when spawned

### 7.2 System limits

The Erlang language specification puts no limits on number of processes, length of atoms etc. but for performance and memory saving reasons there will always be limits in a practical implementation of the Erlang language and execution environment. The current implementation has a few limitations that is good to know about since some of them can be of great importance for the design of an application.

Processes
  The maximum number of simultaneously alive Erlang processes is 32768.
Distributed nodes
  The maximum number of distributed nodes that one Erlang node can connect to during its life time is 255. It can be less than 255 for several mostly platform dependent reasons, for example the maximum number of open file descriptors allowed for a process on the operating system.
Characters in an atom
  255
Atoms
  The maximum number of atoms is 1048576.
Ets-tables
  default=1400, can be changed with the environment variable `ERL_MAX_ETS_TABLES`.
Elements in a tuple
  The maximum number of elements in a tuple is 67108863 (26 bit unsigned integer). Other factors such as the available memory can of course make it hard to create a tuple of that size.
Length of binary
  Unsigned
Total amount of data allocated by an Erlang node
  The Erlang runtime system can use the whole 32 bit address space, but the operating system often limits one single process to use less than that.
length of a nodename
  An Erlang node name has the form host@shortname or host@longname. The nodename is used as an atom within the system so the maximum size of 255 holds for the nodename too.
Open files, ports and sockets
Number of arguments to a function or fun

Copyright © 1991-2002 Ericsson Utvecklings AB