ByteCount[expr]
给出 Wolfram 系统内部存放 expr 所需的字节数.
ByteCount
ByteCount[expr]
给出 Wolfram 系统内部存放 expr 所需的字节数.
范例
打开所有单元 关闭所有单元基本范例 (2)
ByteCount[{1, 2, 3, 4, 5}]ByteCount[Range[10000]]为不同类型的表达式绘制 ByteCount:
DiscretePlot[ByteCount[Range[n]], {n, 100}]DiscretePlot[ByteCount[Integrate[1 / (1 + x ^ n), x]], {n, 30}]DiscretePlot[ByteCount[Sum[1 / (1 + x + x ^ n), x]], {n, 30}]应用 (3)
Table[ByteCount[Integrate[1 / (x ^ n - 1), x]], {n, 10}]用 Simplify 选取有着最小 ByteCount 的表达式:
Simplify[50Log[10000], ComplexityFunction -> ByteCount]LeafCount 不计算出数的大小:
Simplify[50Log[10000], ComplexityFunction -> LeafCount]DiscretePlot[{ByteCount[Range[n]], ByteCount[ReplacePart[Range[n], x, 1]]}, {n, 20}]属性和关系 (8)
ByteCount[Range[1000]]ByteCount[Range[1., 1000]]ByteCount 在实际存放表达式时假设所有子表达式都不共用:
x = 1000!;ByteCount[x]ByteCount[{x, x, x}]ByteCount[s]对于 ASCII 串,平均每个字符 ByteCount 增长 1:
Table[StringJoin[Table["x", {n}]], {n, 10}]ByteCount /@ %DiscretePlot[ByteCount[StringJoin[Table["x", {n}]]], {n, 100}]Table[StringJoin[Table["α", {n}]], {n, 10}]ByteCount /@ %Table[FromDigits[Table[5, {n}]], {n, 15}]ByteCount /@ %DiscretePlot[ByteCount[FromDigits[Table[5, {n}]]], {n, 100}]Fit[Table[ByteCount[FromDigits[Table[5, {n}]]], {n, 1000}], {1, n}, n]Table[Table[x, {n}], {n, 5}]ByteCount /@ %DiscretePlot[ByteCount[Table[x, {n}]], {n, 50}]MemoryConstrained 可中止超出指定 ByteCount 的表达式的生成:
ByteCount[Range[10 ^ 6]]MemoryConstrained[Range[10 ^ 6], 10000]可能存在的问题 (2)
ByteCount[Range[1., 1000]]ByteCount[Prepend[Range[1., 1000], 0]]对于外部对象,ByteCount 仅给出句柄的大小:
ByteCount[SelectedNotebook[]]技术笔记
-
▪
- 内存管理
相关指南
-
▪
- 内存测量和优化 ▪
- 调整和调试 ▪
- 表达式结构 ▪
- GPU 计算 ▪
- NVIDIA GPU 计算 ▪
- Apple GPU 计算
相关的工作流程
- 找出笔记本的大小
历史
1988年引入 (1.0)
文本
Wolfram Research (1988),ByteCount,Wolfram 语言函数,https://reference.wolfram.com/language/ref/ByteCount.html.
CMS
Wolfram 语言. 1988. "ByteCount." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/ByteCount.html.
APA
Wolfram 语言. (1988). ByteCount. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/ByteCount.html 年
BibTeX
@misc{reference.wolfram_2026_bytecount, author="Wolfram Research", title="{ByteCount}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/ByteCount.html}", note=[Accessed: 19-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_bytecount, organization={Wolfram Research}, title={ByteCount}, year={1988}, url={https://reference.wolfram.com/language/ref/ByteCount.html}, note=[Accessed: 19-June-2026]}