├── .travis.yml ├── LICENSE ├── README.markdown ├── doc ├── edoc-info ├── erlang.png ├── erlang_term.html ├── index.html ├── modules-frame.html ├── overview-summary.html └── stylesheet.css ├── erlang_bugs_email.txt ├── mix.exs ├── rebar.config └── src ├── erlang_term.app.src └── erlang_term.erl /.travis.yml: -------------------------------------------------------------------------------- 1 | language: erlang 2 | otp_release: 3 | - 26.1.1 4 | - 25.3.2.6 5 | - 24.3.1 6 | - 23.3.1 7 | - 22.3.4.25 8 | before_script: 9 | script: 10 | - rebar3 compile 11 | - rebar3 eunit 12 | after_script: 13 | - rebar3 clean 14 | branches: 15 | only: 16 | - master 17 | notifications: 18 | email: 19 | recipients: 20 | - mjtruog@gmail.com 21 | irc: 22 | channels: 23 | - "irc.oftc.net#cloudi" 24 | template: 25 | - "%{repository_slug} (%{branch} - %{commit}) %{author}: %{commit_message}" 26 | - "View Changes %{compare_url}" 27 | - "Build #%{build_number}: %{message} (%{build_url})" 28 | on_success: change 29 | on_failure: always 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2014-2023 Michael Truog 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the "Software"), 7 | to deal in the Software without restriction, including without limitation 8 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | and/or sell copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | Erlang Term Info (Memory Consumption) 2 | ===================================== 3 | 4 | [![Build Status](https://app.travis-ci.com/okeuday/erlang_term.svg?branch=master)](https://app.travis-ci.com/okeuday/erlang_term) 5 | 6 | Purpose 7 | ------- 8 | 9 | To provide the in-memory size of Erlang terms, ignoring where the Erlang terms 10 | are stored. 11 | 12 | Size information should match the [Erlang Efficiency Guide memory information](http://www.erlang.org/doc/efficiency_guide/advanced.html#id68923): 13 | 14 | * Small integer: 1 word 15 | * On 32-bit architectures: -134217729 < i < 134217728 (28 bits) 16 | * On 64-bit architectures: -576460752303423489 < i < 576460752303423488 (60 bits) 17 | * Big integer: 3..N words 18 | * Atom: 1 word 19 | * Float: 20 | * On 32-bit architectures: 4 words 21 | * On 64-bit architectures: 3 words 22 | * Binary: 3..6 + data 23 | * List: 1 word + 1 word per element + the size of each element 24 | * Tuple: 2 words + the size of each element 25 | * Small Map (N =< 32): 5 words + the size of all keys and values 26 | * Large Map (N > 32): N * [1.6 .. 1.8] + the size of all keys and values 27 | * Pid: 28 | * From local node: 1 word 29 | * From remote node: 5 words 30 | * Port: 31 | * From local node: 1 word 32 | * From remote node: 5 words 33 | * Reference: 34 | * On 32-bit architectures: 35 | * From local node: 5 words 36 | * From remote node: 7 words 37 | * On 64-bit architectures: 38 | * From local node: 4 words 39 | * From remote node: 6 words 40 | * Fun: 9..13 words + size of environment 41 | * Erlang process: 338 words when spawned (includes a heap of 233 words) 42 | 43 | Limitations 44 | ----------- 45 | 46 | * Binaries are not tracked to avoid counting a reference more than once 47 | (to avoid the extra latency and memory use) 48 | 49 | License 50 | ------- 51 | 52 | MIT License 53 | 54 | Contact 55 | ------- 56 | 57 | Michael Truog (mjtruog at protonmail dot com) 58 | 59 | Thanks 60 | ------ 61 | 62 | * Sverker Eriksson [`erts_debug:flat_size/1` info](erlang_bugs_email.txt) 63 | 64 | -------------------------------------------------------------------------------- /doc/edoc-info: -------------------------------------------------------------------------------- 1 | %% encoding: UTF-8 2 | {application,erlang_term}. 3 | {modules,[erlang_term]}. 4 | -------------------------------------------------------------------------------- /doc/erlang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okeuday/erlang_term/601f87be0b8040f0dabb11ad1ecf5ab51d8589b9/doc/erlang.png -------------------------------------------------------------------------------- /doc/erlang_term.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Module erlang_term 6 | 7 | 8 | 9 | 10 |
11 | 12 |

Module erlang_term

13 | 14 |

Erlang Term Info

. 15 |

Copyright © 2014-2022 Michael Truog

16 | 17 |

Version: 2.0.5 Oct 11 2022 19:35:26 18 | ------------------------------------------------------------------------

19 |

Authors: Michael Truog (mjtruog at protonmail dot com).

20 | 21 |

Description

22 |

Erlang Term Info

23 | 24 |

Function Index

25 | 26 | 27 |
byte_size/1
byte_size/2
28 | 29 |

Function Details

30 | 31 |

byte_size/1

32 |
33 |

byte_size(Term) -> any()

34 |

35 |
36 | 37 |

byte_size/2

38 |
39 |

byte_size(Term, WordSize) -> any()

40 |

41 |
42 |
43 | 44 | 45 |

Generated by EDoc

46 | 47 | 48 | -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The erlang_term application 5 | 6 | 7 | 8 | 9 | 10 | 11 | <h2>This page uses frames</h2> 12 | <p>Your browser does not accept frames. 13 | <br>You should go to the <a href="overview-summary.html">non-frame version</a> instead. 14 | </p> 15 | 16 | 17 | -------------------------------------------------------------------------------- /doc/modules-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The erlang_term application 5 | 6 | 7 | 8 |

Modules

9 | 10 |
erlang_term
11 | 12 | -------------------------------------------------------------------------------- /doc/overview-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | The erlang_term application 6 | 7 | 8 | 9 | 10 |

The erlang_term application

11 | 12 |
13 | 14 |

Generated by EDoc

15 | 16 | 17 | -------------------------------------------------------------------------------- /doc/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* standard EDoc style sheet */ 2 | body { 3 | font-family: Verdana, Arial, Helvetica, sans-serif; 4 | margin-left: .25in; 5 | margin-right: .2in; 6 | margin-top: 0.2in; 7 | margin-bottom: 0.2in; 8 | color: #000000; 9 | background-color: #ffffff; 10 | } 11 | h1,h2 { 12 | margin-left: -0.2in; 13 | } 14 | div.navbar { 15 | background-color: #add8e6; 16 | padding: 0.2em; 17 | } 18 | h2.indextitle { 19 | padding: 0.4em; 20 | background-color: #add8e6; 21 | } 22 | h3.function,h3.typedecl { 23 | background-color: #add8e6; 24 | padding-left: 1em; 25 | } 26 | div.spec { 27 | margin-left: 2em; 28 | background-color: #eeeeee; 29 | } 30 | a.module { 31 | text-decoration:none 32 | } 33 | a.module:hover { 34 | background-color: #eeeeee; 35 | } 36 | ul.definitions { 37 | list-style-type: none; 38 | } 39 | ul.index { 40 | list-style-type: none; 41 | background-color: #eeeeee; 42 | } 43 | 44 | /* 45 | * Minor style tweaks 46 | */ 47 | ul { 48 | list-style-type: square; 49 | } 50 | table { 51 | border-collapse: collapse; 52 | } 53 | td { 54 | padding: 3 55 | } 56 | -------------------------------------------------------------------------------- /erlang_bugs_email.txt: -------------------------------------------------------------------------------- 1 | Delivered-To: mjtruog at gmail dot com 2 | Return-Path: 3 | Date: Fri, 26 Sep 2014 15:46:44 +0200 4 | From: Sverker Eriksson 5 | To: Michael Truog 6 | CC: 7 | Subject: Re: [erlang-bugs] erts_debug:flat_size/1 wrong? 8 | Content-Type: text/plain; charset="windows-1252"; format=flowed 9 | Content-Transfer-Encoding: 7bit 10 | Return-Path: sverker.eriksson at ericsson dot com 11 | 12 | On 09/26/2014 04:19 AM, Michael Truog wrote: 13 | > Hi, 14 | > 15 | > I have been attempting to compare the output of erts_debug:flat_size/1 16 | > to the memory info at 17 | > http://www.erlang.org/doc/efficiency_guide/advanced.html#id68923 and 18 | > the results show that each term's size is off-by-one (at least for 19 | > pids local/remote, refs local/remote, floats, integers, bignums, 20 | > binaries and atoms). I know the function is experimental, but this is 21 | > a bug, right? The problem affects top-level terms and nested terms, 22 | > so it is likely to understate the memory with large terms. I wanted 23 | > to make sure the memory info (in the efficiency guide) was accurate 24 | > (it seems like it is). I was testing with R16B03 on 64bits. 25 | > 26 | > For example: 27 | > 1> erts_debug:flat_size(576460752303423488). 28 | > 2 29 | > 2> erts_debug:flat_size(576460752303423487). 30 | > 0 31 | > 3> erts_debug:flat_size(undefined). 32 | > 0 33 | > 4> erts_debug:flat_size([]). 34 | > 0 35 | > 5> erts_debug:flat_size([undefined]). 36 | > 2 37 | > % 1 word for each element in the list * 2 elements including [] 38 | > 6> erts_debug:flat_size(erlang:make_ref()). 39 | > 3 40 | > 7> erts_debug:flat_size(erlang:self()). 41 | > 0 42 | > 8> erts_debug:flat_size(1.0). 43 | > 2 44 | > 45 | 46 | 47 | erts_debug:flat_size/1 is undocumented and can therefor not be wrong by 48 | definition :-) 49 | 50 | But no, there is no bug, erts_debug:flat_size/1 works as intended in the 51 | current implementation. It returns the number of words on the _heap_ 52 | occupied (*) by the term. Excluded are thus off-heap data such as 53 | binaries larger than 64 bytes AND the top term word, which is kept in a 54 | register or on the stack. 55 | 56 | (*) erts_debug:flat_size does not take sharing of sub-terms into account 57 | while erts_debug:size/1 do. 58 | 59 | 1> A = "Hello". 60 | "Hello" 61 | 2> erts_debug:flat_size(A). 62 | 10 63 | 3> erts_debug:flat_size({A,A}). 64 | 23 65 | 4> erts_debug:size({A,A}). 66 | 13 67 | 68 | 69 | /Sverker, Erlang/OTP 70 | -------------------------------------------------------------------------------- /mix.exs: -------------------------------------------------------------------------------- 1 | #-*-Mode:elixir;coding:utf-8;tab-width:2;c-basic-offset:2;indent-tabs-mode:()-*- 2 | # ex: set ft=elixir fenc=utf-8 sts=2 ts=2 sw=2 et nomod: 3 | 4 | defmodule ErlangTerm.Mixfile do 5 | use Mix.Project 6 | 7 | def project do 8 | [app: :erlang_term, 9 | version: "2.0.7", 10 | language: :erlang, 11 | erlc_options: [ 12 | {:d, :erlang.list_to_atom('ERLANG_OTP_VERSION_' ++ :erlang.system_info(:otp_release))}, 13 | :deterministic, 14 | :debug_info, 15 | :warn_export_vars, 16 | :warn_unused_import, 17 | #:warn_missing_spec, 18 | :warnings_as_errors], 19 | description: description(), 20 | package: package(), 21 | deps: deps()] 22 | end 23 | 24 | defp deps do 25 | [] 26 | end 27 | 28 | defp description do 29 | "Provide the in-memory size of Erlang terms" 30 | end 31 | 32 | defp package do 33 | [files: ~w(src doc rebar.config README.markdown LICENSE), 34 | maintainers: ["Michael Truog"], 35 | licenses: ["MIT"], 36 | links: %{"GitHub" => "https://github.com/okeuday/erlang_term"}] 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /rebar.config: -------------------------------------------------------------------------------- 1 | %-*-Mode:erlang;coding:utf-8;tab-width:4;c-basic-offset:4;indent-tabs-mode:()-*- 2 | % ex: set ft=erlang fenc=utf-8 sts=4 ts=4 sw=4 et nomod: 3 | 4 | {erl_opts, 5 | [{platform_define, "^R16", 'ERLANG_OTP_VERSION_16'}, 6 | {platform_define, "^17\.", 'ERLANG_OTP_VERSION_17'}, 7 | {platform_define, "^18\.", 'ERLANG_OTP_VERSION_18'}, 8 | {platform_define, "^19\.", 'ERLANG_OTP_VERSION_19'}, 9 | {platform_define, "^20\.", 'ERLANG_OTP_VERSION_20'}, 10 | warn_export_vars, 11 | warn_unused_import, 12 | %warn_missing_spec, 13 | warnings_as_errors]}. 14 | {edoc_opts, [{preprocess, true}]}. 15 | -------------------------------------------------------------------------------- /src/erlang_term.app.src: -------------------------------------------------------------------------------- 1 | %-*-Mode:erlang;coding:utf-8;tab-width:4;c-basic-offset:4;indent-tabs-mode:()-*- 2 | % ex: set ft=erlang fenc=utf-8 sts=4 ts=4 sw=4 et: 3 | 4 | {application, erlang_term, 5 | [{description, "Erlang Term Info"}, 6 | {vsn, "2.0.7"}, 7 | {modules, [erlang_term]}, 8 | {registered, []}, 9 | {applications, [stdlib, kernel]}]}. 10 | -------------------------------------------------------------------------------- /src/erlang_term.erl: -------------------------------------------------------------------------------- 1 | %-*-Mode:erlang;coding:utf-8;tab-width:4;c-basic-offset:4;indent-tabs-mode:()-*- 2 | % ex: set ft=erlang fenc=utf-8 sts=4 ts=4 sw=4 et nomod: 3 | %%% 4 | %%%------------------------------------------------------------------------ 5 | %%% @doc 6 | %%% ==Erlang Term Info== 7 | %%% @end 8 | %%% 9 | %%% MIT License 10 | %%% 11 | %%% Copyright (c) 2014-2024 Michael Truog 12 | %%% 13 | %%% Permission is hereby granted, free of charge, to any person obtaining a 14 | %%% copy of this software and associated documentation files (the "Software"), 15 | %%% to deal in the Software without restriction, including without limitation 16 | %%% the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | %%% and/or sell copies of the Software, and to permit persons to whom the 18 | %%% Software is furnished to do so, subject to the following conditions: 19 | %%% 20 | %%% The above copyright notice and this permission notice shall be included in 21 | %%% all copies or substantial portions of the Software. 22 | %%% 23 | %%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | %%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | %%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | %%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | %%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | %%% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 | %%% DEALINGS IN THE SOFTWARE. 30 | %%% 31 | %%% @author Michael Truog 32 | %%% @copyright 2014-2024 Michael Truog 33 | %%% @version 2.0.8 {@date} {@time} 34 | %%%------------------------------------------------------------------------ 35 | 36 | -module(erlang_term). 37 | -author('mjtruog at protonmail dot com'). 38 | 39 | %% external interface 40 | -export([byte_size/1, 41 | byte_size/2]). 42 | 43 | -compile({no_auto_import, 44 | [byte_size/1, 45 | byte_size/2]}). 46 | 47 | -define(HEAP_BINARY_LIMIT, 64). 48 | 49 | -ifdef(ERLANG_OTP_VERSION_16). 50 | -else. 51 | -define(ERLANG_OTP_VERSION_17_FEATURES, true). 52 | -ifdef(OTP_RELEASE). % Erlang/OTP >= 21.0 53 | -if(?OTP_RELEASE >= 25). 54 | -define(ERLANG_OTP_VERSION_25_FEATURES, true). 55 | -if(?OTP_RELEASE >= 27). 56 | -define(ERLANG_OTP_VERSION_27_FEATURES, true). 57 | -endif. 58 | -endif. 59 | -endif. 60 | -endif. 61 | -ifdef(ERLANG_OTP_VERSION_17_FEATURES). 62 | -define(BYTE_SIZE_TERMS_MAP, 63 | ; 64 | byte_size_terms(Term) 65 | when is_map(Term) -> 66 | maps:fold(fun(K, V, Bytes) -> 67 | byte_size_terms(K) + byte_size_terms(V) + Bytes 68 | end, 0, Term) 69 | ;). 70 | -else. 71 | -define(BYTE_SIZE_TERMS_MAP, 72 | ;). 73 | -endif. 74 | 75 | %%%------------------------------------------------------------------------ 76 | %%% External interface functions 77 | %%%------------------------------------------------------------------------ 78 | 79 | byte_size(Term) -> 80 | byte_size(Term, erlang:system_info(wordsize)). 81 | 82 | byte_size(Term, WordSize) -> 83 | byte_size_term_local(Term, WordSize) + 84 | byte_size_terms(Term). 85 | 86 | %%%------------------------------------------------------------------------ 87 | %%% Private functions 88 | %%%------------------------------------------------------------------------ 89 | 90 | byte_size_terms(Term) 91 | when is_list(Term) -> 92 | byte_size_terms_in_list(Term); 93 | byte_size_terms(Term) 94 | when is_tuple(Term) -> 95 | if 96 | Term == {} -> 97 | 0; 98 | true -> 99 | byte_size_terms_in_tuple(1, erlang:tuple_size(Term), Term) 100 | end 101 | ?BYTE_SIZE_TERMS_MAP 102 | byte_size_terms(Term) -> 103 | byte_size_term(Term). 104 | 105 | byte_size_terms_in_list([]) -> 106 | 0; 107 | byte_size_terms_in_list([Term | L]) -> 108 | byte_size_terms(Term) + 109 | byte_size_terms_in_list(L); 110 | byte_size_terms_in_list(Term) -> 111 | byte_size_terms(Term). % element of improper list 112 | 113 | byte_size_terms_in_tuple(Size, Size, Term) -> 114 | byte_size_terms(erlang:element(Size, Term)); 115 | byte_size_terms_in_tuple(I, Size, Term) -> 116 | byte_size_terms(erlang:element(I, Term)) + 117 | byte_size_terms_in_tuple(I + 1, Size, Term). 118 | 119 | byte_size_term(Term) -> 120 | byte_size_term_global(Term). 121 | 122 | byte_size_term_local(Term, WordSize) -> 123 | % stack/register size + heap size 124 | (1 + erts_debug:flat_size(Term)) * WordSize. 125 | 126 | byte_size_term_global(Term) 127 | when is_binary(Term) -> 128 | % global data storage within allocators 129 | BinarySize = erlang:byte_size(Term), 130 | if 131 | BinarySize > ?HEAP_BINARY_LIMIT -> 132 | % refc binary 133 | BinarySize; 134 | true -> 135 | % heap binary 136 | 0 137 | end; 138 | byte_size_term_global(_) -> 139 | 0. 140 | 141 | -ifdef(TEST). 142 | -include_lib("eunit/include/eunit.hrl"). 143 | 144 | -ifdef(CLOUDI_TEST_TIMEOUT). 145 | -define(TEST_TIMEOUT, ?CLOUDI_TEST_TIMEOUT). % seconds 146 | -else. 147 | -define(TEST_TIMEOUT, 10). % seconds 148 | -endif. 149 | 150 | -ifdef(ERLANG_OTP_VERSION_27_FEATURES). 151 | -define(INTERNAL_TEST_REFC_BINARY, 152 | 9 = 1 + erts_debug:flat_size(RefcBinary), 153 | ). 154 | -else. 155 | -define(INTERNAL_TEST_REFC_BINARY, 156 | 7 = 1 + erts_debug:flat_size(RefcBinary), 157 | ). 158 | -endif. 159 | 160 | -ifdef(ERLANG_OTP_VERSION_17_FEATURES). 161 | -ifdef(ERLANG_OTP_VERSION_27_FEATURES). 162 | -define(INTERNAL_TEST_MAP, 163 | 88 = byte_size(#{1=>1, 2=>2, 3=>3}, 8), 164 | 152 = byte_size(#{1=>RefcBinary, 2=>2, 3=>3}, 8) - 165 | erlang:byte_size(RefcBinary), 166 | ). 167 | -else. 168 | -define(INTERNAL_TEST_MAP, 169 | 88 = byte_size(#{1=>1, 2=>2, 3=>3}, 8), 170 | 136 = byte_size(#{1=>RefcBinary, 2=>2, 3=>3}, 8) - 171 | erlang:byte_size(RefcBinary), 172 | ). 173 | -endif. 174 | -else. 175 | -define(INTERNAL_TEST_MAP, 176 | ok, 177 | ). 178 | -endif. 179 | 180 | -ifdef(ERLANG_OTP_VERSION_25_FEATURES). 181 | -ifdef(ERLANG_OTP_VERSION_27_FEATURES). 182 | -define(INTERNAL_TEST_EXTERNAL_FUNCTION, 183 | 48 = byte_size({fun module:function/0, []}, 8), 184 | ). 185 | -else. 186 | -define(INTERNAL_TEST_EXTERNAL_FUNCTION, 187 | 72 = byte_size({fun module:function/0, []}, 8), 188 | ). 189 | -endif. 190 | -define(INTERNAL_TEST_TUPLE_EMPTY, 191 | 8 = byte_size({}, 8), 192 | 32 = byte_size(#{}, 8), 193 | ). 194 | -else. 195 | -define(INTERNAL_TEST_EXTERNAL_FUNCTION, 196 | 48 = byte_size({fun module:function/0, []}, 8), 197 | ). 198 | -ifdef(ERLANG_OTP_VERSION_17_FEATURES). 199 | -define(INTERNAL_TEST_TUPLE_EMPTY, 200 | 16 = byte_size({}, 8), 201 | 40 = byte_size(#{}, 8), 202 | ). 203 | -else. 204 | -define(INTERNAL_TEST_TUPLE_EMPTY, 205 | 16 = byte_size({}, 8), 206 | ). 207 | -endif. 208 | -endif. 209 | 210 | module_test_() -> 211 | {timeout, ?TEST_TIMEOUT, [ 212 | {"internal tests", ?_assertEqual(ok, t_basic())} 213 | ]}. 214 | 215 | t_basic() -> 216 | RefcBinary = <<1:((?HEAP_BINARY_LIMIT + 1) * 8)>>, 217 | HeapBinary = <<1:(?HEAP_BINARY_LIMIT * 8)>>, 218 | ?INTERNAL_TEST_REFC_BINARY 219 | % doesn't work in the interpreter (console shell) 220 | % (process heap size of binary is excluded 221 | % when executed in the interpreter) 222 | 11 = 1 + erts_debug:flat_size(HeapBinary), 223 | 4 = 1 + erts_debug:flat_size(<<1:8>>), 224 | 225 | 24 = byte_size(<<>>, 8), 226 | 32 = byte_size(<<"abc">>, 8), 227 | 32 = byte_size(<<$a, $b, $c>>, 8), 228 | 8 = byte_size([], 8), 229 | 24 = byte_size([0|[]], 8), 230 | 24 = byte_size([1|2], 8), % improper list 231 | 24 = byte_size({0}, 8), 232 | 32 = byte_size({0,1}, 8), 233 | 8 = byte_size(0, 8), 234 | 8 = byte_size(erlang:self(), 8), 235 | 8 = byte_size(atom, 8), 236 | 40 = byte_size({module, function, []}, 8), 237 | ?INTERNAL_TEST_EXTERNAL_FUNCTION 238 | ?INTERNAL_TEST_TUPLE_EMPTY 239 | ?INTERNAL_TEST_MAP 240 | ok. 241 | 242 | -endif. 243 | 244 | --------------------------------------------------------------------------------