This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Built-in Functions / Memory Usage  /
LeafCount

  • LeafCount[ expr ] gives the total number of indivisible subexpressions in expr.
  • LeafCount gives a measure of the total "size" of an expression.
  • LeafCount counts the number of subexpressions in expr which correspond to "leaves" on the expression tree.
  • Example: LeafCount[1 + a + b^2].
  • See the Mathematica book: Section 2.13.4.
  • See also: ByteCount, Length, Depth, AtomQ.

    Further Examples

    Here are two cases where it helps to see the internal representation.

    In[1]:=

    Out[1]=

    In[2]:=

    Out[2]//FullForm=

    In[3]:=

    Out[3]=

    In[4]:=

    Out[4]//FullForm=