[erlang-questions] Unstable erlang compared to java or perl

Petter Egesund <>
Sun Nov 7 22:50:39 CET 2010


Yes, the words vs bytes theory might explain something :-)

I know about delete - I allready do that, the ets-tables which appear
in the list are expected. They belong to not-finished processes.

Some math then:

Summing the ets:i() info gives about 631747158 words which corresponds
to 5562163256 bytes, meaning that each word is using 8 bytes, which
makes sense on a 64-bit operating system to me.

Using this line as an example shows that each entry in ets (entry is
key/value, both tuples with three integers), show that each integer
needs 113336012 * 8 / 5425194 = 167 bytes (or 27 bytes pr. integer):

 6746271765      the_synapses      ordered_set 5425194 113336012 <0.47.0>

This is what tricked me - erlang is using much space serializing data
than the other languages - I will try to store my data as binary and
see if that helps.

Thanks!

Petter


On Sun, Nov 7, 2010 at 10:28 PM, Ryan Zezeski <> wrote:
>
>
> On Sun, Nov 7, 2010 at 4:21 PM, Jesper Louis Andersen
> <> wrote:
>>
>> On Sun, Nov 7, 2010 at 10:15 PM, Petter Egesund
>> <> wrote:
>>
>> > Full source code? It is unfortunately to long and to data-bound to
>> > make sense. Still hoping for a clue - ets:i() tells me that total ets
>> > should be less than to 1 gb total, but memory() says it is using more
>> > than 5 gb for ets.
>>
>> ets:i/0 reports words.
>> erlang:memory/0 reports bytes.
>>
>> So that should not be surprising that they differ by a factor of 4.
>>
>> --
>> J.
>
> Jesper beat me to it...the memory reported by ets:info and ets:i is in
> words...not bytes.
> Petter, I don't think you're actually deleting these tables, which is proven
> by the fact that they show up in ets:i/0.  I'll say it again, they are not
> garbage collected...they don't live on the process heap.  THere are two ways
> to delete an ETS table: 1) call ets:delete or 2) the owner dies and there is
> no heir.  When they are deleted  the memory is reclaimed.
> Here is a erl session showing what I mean...
> 1> ets:i().
>  id              name              type  size   mem      owner
>  ----------------------------------------------------------------------------
>  13              code              set   257    10711    code_server
>  4110            code_names        set   57     7754     code_server
>  8207            shell_records     ordered_set 0      112      <0.25.0>
>  ac_tab          ac_tab            set   6      878
>  application_controller
>  file_io_servers file_io_servers   set   0      322      file_server_2
>  global_locks    global_locks      set   0      322      global_name_server
>  global_names    global_names      set   0      322      global_name_server
>  global_names_ext global_names_ext  set   0      322      global_name_server
>  global_pid_ids  global_pid_ids    bag   0      322      global_name_server
>  global_pid_names global_pid_names  bag   0      322      global_name_server
>  inet_cache      inet_cache        bag   0      322      inet_db
>  inet_db         inet_db           set   29     706      inet_db
>  inet_hosts_byaddr inet_hosts_byaddr bag   0      322      inet_db
>  inet_hosts_byname inet_hosts_byname bag   0      322      inet_db
>  inet_hosts_file_byaddr inet_hosts_file_byaddr bag   0      322      inet_db
>  inet_hosts_file_byname inet_hosts_file_byname bag   0      322      inet_db
> ok
> 2> ets:new(test, [public, named_table]).
> test
> 3> ets:i().
>  id              name              type  size   mem      owner
>  ----------------------------------------------------------------------------
>  13              code              set   257    10711    code_server
>  4110            code_names        set   57     7754     code_server
>  8207            shell_records     ordered_set 0      112      <0.25.0>
>  ac_tab          ac_tab            set   6      878
>  application_controller
>  file_io_servers file_io_servers   set   0      322      file_server_2
>  global_locks    global_locks      set   0      322      global_name_server
>  global_names    global_names      set   0      322      global_name_server
>  global_names_ext global_names_ext  set   0      322      global_name_server
>  global_pid_ids  global_pid_ids    bag   0      322      global_name_server
>  global_pid_names global_pid_names  bag   0      322      global_name_server
>  inet_cache      inet_cache        bag   0      322      inet_db
>  inet_db         inet_db           set   29     706      inet_db
>  inet_hosts_byaddr inet_hosts_byaddr bag   0      322      inet_db
>  inet_hosts_byname inet_hosts_byname bag   0      322      inet_db
>  inet_hosts_file_byaddr inet_hosts_file_byaddr bag   0      322      inet_db
>  inet_hosts_file_byname inet_hosts_file_byname bag   0      322      inet_db
>  test            test              set   0      322      <0.31.0>
> ok
> 4> ets:delete(test).
> true
> 5> ets:i().
>  id              name              type  size   mem      owner
>  ----------------------------------------------------------------------------
>  13              code              set   257    10711    code_server
>  4110            code_names        set   57     7754     code_server
>  8207            shell_records     ordered_set 0      112      <0.25.0>
>  ac_tab          ac_tab            set   6      878
>  application_controller
>  file_io_servers file_io_servers   set   0      322      file_server_2
>  global_locks    global_locks      set   0      322      global_name_server
>  global_names    global_names      set   0      322      global_name_server
>  global_names_ext global_names_ext  set   0      322      global_name_server
>  global_pid_ids  global_pid_ids    bag   0      322      global_name_server
>  global_pid_names global_pid_names  bag   0      322      global_name_server
>  inet_cache      inet_cache        bag   0      322      inet_db
>  inet_db         inet_db           set   29     706      inet_db
>  inet_hosts_byaddr inet_hosts_byaddr bag   0      322      inet_db
>  inet_hosts_byname inet_hosts_byname bag   0      322      inet_db
>  inet_hosts_file_byaddr inet_hosts_file_byaddr bag   0      322      inet_db
>  inet_hosts_file_byname inet_hosts_file_byname bag   0      322      inet_db
> ok
>


More information about the erlang-questions mailing list