gives the number of bytes used internally by the Wolfram System to store expr.


  • ByteCount does not take account of any sharing of subexpressions. The results it gives assume that every part of the expression is stored separately. ByteCount will therefore often give an overestimate of the amount of memory currently needed to store a particular expression. When you manipulate the expression, however, subexpressions will often stop being shared, and the amount of memory needed will be close to the value returned by ByteCount. »
  • Symbols are effectively always shared, so have a byte count of zero. »
  • Results from ByteCount may be different on different computer systems.


open allclose all

Basic Examples  (2)

Find the number of bytes used to store an expression:

Plot the ByteCount for different types of expressions:

Applications  (3)

Growth of storage sizes for a sequence of integrals:

Make Simplify pick expressions with minimum ByteCount:

LeafCount does not account for sizes of numbers:

Show that lists with symbolic elements require more storage than lists of numbers:

Properties & Relations  (8)

On the computer system used for this example, each ordinary integer takes 4 bytes to store:

Approximate numbers take double:

ByteCount does not account for sharing in the actual storage of expressions:

Symbols are effectively always shared, so they give 0 byte count:

For ASCII strings, ByteCount on average increases by 1 for each character:

Unicode characters on average add 2 bytes each:

For integers, there is a jump in going beyond machine numbers:

The average rate of increase is about 0.4 bytes per decimal digit:

Each element of a list effectively adds an internal pointer:

MemoryConstrained aborts the generation of expressions that exceed a specified ByteCount:

Possible Issues  (2)

Small changes can have large effects on memory usage:

The presence of the exact 0 prevents the data from being packed:

ByteCount only gives the size of handles to external objects:

Wolfram Research (1988), ByteCount, Wolfram Language function,


Wolfram Research (1988), ByteCount, Wolfram Language function,


Wolfram Language. 1988. "ByteCount." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (1988). ByteCount. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_bytecount, author="Wolfram Research", title="{ByteCount}", year="1988", howpublished="\url{}", note=[Accessed: 26-May-2024 ]}


@online{reference.wolfram_2024_bytecount, organization={Wolfram Research}, title={ByteCount}, year={1988}, url={}, note=[Accessed: 26-May-2024 ]}