aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_process_dump.c
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2013-05-16 09:46:42 +0200
committerLukas Larsson <[email protected]>2013-05-16 09:46:42 +0200
commit54f5cea53853351ecd0042ebe0e9b9bdc1ba4449 (patch)
tree8958c9619f1a0958894c3e3dfa41f06b4f42b722 /erts/emulator/beam/erl_process_dump.c
parent8992e61d3fe98c246f00a2b701fba6c54567582e (diff)
parent9116b4b6a19e18c926d218b325dfa6ddd4e04f41 (diff)
downloadotp-54f5cea53853351ecd0042ebe0e9b9bdc1ba4449.tar.gz
otp-54f5cea53853351ecd0042ebe0e9b9bdc1ba4449.tar.bz2
otp-54f5cea53853351ecd0042ebe0e9b9bdc1ba4449.zip
Merge branch 'lukas/erts/process_memory_crash_dump/OTP-11098' into maint
* lukas/erts/process_memory_crash_dump/OTP-11098: Print process memory usage info in crash dump
Diffstat (limited to 'erts/emulator/beam/erl_process_dump.c')
-rw-r--r--erts/emulator/beam/erl_process_dump.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_process_dump.c b/erts/emulator/beam/erl_process_dump.c
index a93229c473..6cd0d23b97 100644
--- a/erts/emulator/beam/erl_process_dump.c
+++ b/erts/emulator/beam/erl_process_dump.c
@@ -76,6 +76,43 @@ erts_deep_process_dump(int to, void *to_arg)
dump_binaries(to, to_arg, all_binaries);
}
+Uint erts_process_memory(Process *p) {
+ ErlMessage *mp;
+ Uint size = 0;
+ struct saved_calls *scb;
+ size += sizeof(Process);
+
+ ERTS_SMP_MSGQ_MV_INQ2PRIVQ(p);
+
+ erts_doforall_links(ERTS_P_LINKS(p), &erts_one_link_size, &size);
+ erts_doforall_monitors(ERTS_P_MONITORS(p), &erts_one_mon_size, &size);
+ size += (p->heap_sz + p->mbuf_sz) * sizeof(Eterm);
+ if (p->old_hend && p->old_heap)
+ size += (p->old_hend - p->old_heap) * sizeof(Eterm);
+
+ size += p->msg.len * sizeof(ErlMessage);
+
+ for (mp = p->msg.first; mp; mp = mp->next)
+ if (mp->data.attached)
+ size += erts_msg_attached_data_size(mp)*sizeof(Eterm);
+
+ if (p->arg_reg != p->def_arg_reg) {
+ size += p->arity * sizeof(p->arg_reg[0]);
+ }
+
+ if (p->psd)
+ size += sizeof(ErtsPSD);
+
+ scb = ERTS_PROC_GET_SAVED_CALLS_BUF(p);
+ if (scb) {
+ size += (sizeof(struct saved_calls)
+ + (scb->len-1) * sizeof(scb->ct[0]));
+ }
+
+ size += erts_dicts_mem_size(p);
+ return size;
+}
+
static void
dump_process_info(int to, void *to_arg, Process *p)
{