From b0ac4b37836f27a6ca2cbf5cf4b5d3cb3e1f842c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 15 Nov 2022 23:38:08 -0800 Subject: [PATCH] command: snapshot stats on memory footprint --- ...renceInfo.lua.unused => MemoryReferenceInfo.lua | 0 commands.lua | 14 ++++++++++++++ 2 files changed, 14 insertions(+) rename MemoryReferenceInfo.lua.unused => MemoryReferenceInfo.lua (100%) diff --git a/MemoryReferenceInfo.lua.unused b/MemoryReferenceInfo.lua similarity index 100% rename from MemoryReferenceInfo.lua.unused rename to MemoryReferenceInfo.lua diff --git a/commands.lua b/commands.lua index e2872da..d9a6d47 100644 --- a/commands.lua +++ b/commands.lua @@ -59,6 +59,7 @@ Commands = { 'reload all from disk', 'delete note at cursor from disk (if possible)', 'copy selection to clipboard (ctrl+c)', + 'snapshot summary of memory use to disk', }, editable={ 'exit editing (ctrl+e)', @@ -513,6 +514,8 @@ function run_command(cmd, args) command.reload_note() elseif cmd == 'delete note at cursor from disk' then command.delete_note() + elseif cmd == 'snapshot summary of memory use to disk' then + command.snapshot_memory() -- editing elseif cmd == 'find in note' then command.send_key_to_current_pane('C-f', 'f') @@ -1559,6 +1562,17 @@ function command.delete_note() command.reload_all() end +function command.snapshot_memory() + -- load library on demand + if mri == nil then + mri = require('MemoryReferenceInfo') + end + collectgarbage('collect') + print(collectgarbage('count')) + mri.m_cMethods.DumpMemorySnapshot('./', 'mem', -1) + add_error('snapshot successfully dumped') +end + function command.send_key_to_current_pane(chord, key) if Cursor_pane.col < 1 then add_error('no current note')