command: snapshot stats on memory footprint

This commit is contained in:
Kartik K. Agaram 2022-11-15 23:38:08 -08:00
parent ca21d924d5
commit b0ac4b3783
2 changed files with 14 additions and 0 deletions

View File

@ -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')