[erlang-questions] Help diagnosing memory usage

Colm Dougan <>
Wed Apr 22 22:58:01 CEST 2009


Hi,

I'm trying to reconcile the output of erlang:memory() vs ets:i() and I
seem to have quite a big discrepancy.

If I run erlang:memory() I get the following:

20> erlang:memory().
[{total,949026552},
 {processes,1089932},
 {processes_used,1080612},
 {system,947936620},
 {atom,742857},
 {atom_used,737735},
 {binary,27760},
 {code,6016281},
 {ets,929695484}]

This matches top which says I am using around 940MB of memory. It
seems the majority of memory is being used by the ETS tables.

So If I run ets:i() I get:

21> ets:i().
 id              name              type  size   mem      owner
 ----------------------------------------------------------------------------
 9               cookies           set   0      288      auth
 4108            code              set   463    36286    code_server
 8205            code_names        set   55     5071     code_server
 12302           shell_records     ordered_set 0      81       <0.32.0>
 20497           ssl_pid_to_file   bag   0      288      ssl_manager
 24594           ssl_otp_session_cache set   0      288      ssl_manager
 32792           dets              duplicate_bag 11     413      dets
 36894           mnesia_subscr     duplicate_bag 1      298      mnesia_subscr
 40991           mnesia_transient_decision set   2      318      mnesia_recover
 53288           cache_manager     set   1      462      cache_manager
 57385           mnesia_index      bag   3796177 51598879 mnesia_monitor
 61482           recv_list         ordered_set 567969 11359461 <0.148.0>
 65579           send_list         ordered_set 3228208 54879617 <0.148.0>
 69684           ca_cert_table     set   203    63539    ca_certificate_manager
 73782           yaws_code         set   2      308      <0.206.0>
 77879           ign_requests      set   0      288      inet_gethost_native
 81976           ign_req_index     set   0      288      inet_gethost_native
 86074           handler_db        set   0      288      httpc_manager
 90171           http_session_cookie_db bag   0      288      httpc_manager
 '+rGSE56USZ99aOORq46fZA==_index' '+rGSE56USZ99aOORq46fZA==_index' bag
  3796177 81968295 mnesia_monitor
 ac_tab          ac_tab            set   121    5568     application_controller
 bfmc_table      bfmc_table        set   0      288      bfmc
 cache_stats     cache_stats       set   1      364      cache_stats
 caches          caches            set   1      347      mnesia_monitor
 client_config_table client_config_table set   0      288      client_config_mgr
 dets_owners     dets_owners       set   6      348      dets
 dets_registry   dets_registry     set   6      354      dets
 disk_log_names  disk_log_names    set   1      299      disk_log_server
 disk_log_pids   disk_log_pids     set   1      298      disk_log_server
 file_io_servers file_io_servers   set   1      358      file_server_2
 global_locks    global_locks      set   0      288      global_name_server
 global_names    global_names      set   0      288      global_name_server
 global_names_ext global_names_ext  set   0      288      global_name_server
 global_pid_ids  global_pid_ids    bag   0      288      global_name_server
 global_pid_names global_pid_names  bag   0      288      global_name_server
 httpc_manager_session_db httpc_manager_session_db set   0      288
  httpc_manager
 inet_cache      inet_cache        bag   0      288      inet_db
 inet_db         inet_db           set   21     510      inet_db
 inet_hosts      inet_hosts        set   0      288      inet_db
 mnesia_decision mnesia_decision   set   1      299      mnesia_recover
 mnesia_gvar     mnesia_gvar       set   173    3521     mnesia_monitor
 mnesia_held_locks mnesia_held_locks bag   0      288      mnesia_monitor
 mnesia_lock_counter mnesia_lock_counter set   0      288      mnesia_monitor
 mnesia_lock_queue mnesia_lock_queue bag   0      288      mnesia_monitor
 mnesia_sticky_locks mnesia_sticky_locks set   0      288      mnesia_monitor
 mnesia_tid_locks mnesia_tid_locks  bag   0      288      mnesia_monitor
 queue_table     queue_table       ordered_set 1      92       writer_service
 schema          schema            set   4      732      mnesia_monitor
 user_stats_collector_client_connection_log
user_stats_collector_client_connection_log bag   0      288
user_stats_collector
 user_stats_collector_client_stats user_stats_collector_client_stats
set   1      349      user_stats_collector
 user_stats_collector_current_dataplane_stats
user_stats_collector_current_dataplane_stats bag   0      288
user_stats_collector
 user_stats_collector_historic_client_stats
user_stats_collector_historic_client_stats set   74     5246
user_stats_collector
 ssl_file_to_ref ssl_file_to_ref   set   0      288      ssl_manager
 ssl_otp_certificate_db ssl_otp_certificate_db set   0      288      ssl_manager
 stats_collector_live_stats_table stats_collector_live_stats_table set
  1      1512     stats_collector
 sys_dist        sys_dist          set   0      288      net_kernel
 timer_interval_tab timer_interval_tab set   6      456      timer_server
 timer_tab       timer_tab         ordered_set 7      312      timer_server
 block_delete_table block_delete_table  set   0      288      mnesia_monitor
 yaws_session_server yaws_session_server set   0      288
yaws_session_server
ok

>From ets:i() I only get about 200MB used!

I can't seem to reconcile the other 740MB.  Can anyone point out what
I'm missing?

Thanks,
Colm



More information about the erlang-questions mailing list