diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-12-25 14:13:37 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2024-12-26 01:49:01 -0500 |
commit | 0a88b818e96b33bbb50ed7b434b761672b93a21b (patch) | |
tree | 4b5798d439669101205bc8f4da8d63f48b966d85 | |
parent | 962e1b2e693c49c032ebfd1140eb05545ccaf32b (diff) | |
download | rockbox-0a88b818e9.tar.gz rockbox-0a88b818e9.zip |
lua make memcheck script eat all available ram (incld audiobuf)
Change-Id: Ia202c9097324985a3a9a9c96be8422c38e79cb3e
-rw-r--r-- | apps/plugins/lua_scripts/memchk.lua | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/apps/plugins/lua_scripts/memchk.lua b/apps/plugins/lua_scripts/memchk.lua index f7619fe3dd..283748b2c2 100644 --- a/apps/plugins/lua_scripts/memchk.lua +++ b/apps/plugins/lua_scripts/memchk.lua @@ -16,6 +16,28 @@ KIND, either express or implied. ]]-- +local a = {} +loops = 1 --global + +local function alloc_tables(loops) + for i=1,loops do a[i] = {{}}; local b = {} end + return true +end + +local ret +local status = true +rb.lcd_putsxy(0, 0, "memchk loops : ") +while (status and loops < 1000) +do + rb.lcd_putsxy(0, 20, loops) + rb.lcd_update() + alloc_tables(loops) + -- do call protected to catch OOM condition + status, ret = pcall(alloc_tables, loops * 1000) + loops = loops + 1 + _G.loops = loops +end + local used, allocd, free = rb.mem_stats() local lu = collectgarbage("count") local fmt = function(t, v) return string.format("%s: %d Kb\n", t, v /1024) end @@ -23,10 +45,13 @@ local fmt = function(t, v) return string.format("%s: %d Kb\n", t, v /1024) end -- this is how lua recommends to concat strings rather than .. local s_t = {} s_t[1] = "rockbox:\n" -s_t[2] = fmt("Used ", used) -s_t[3] = fmt("Allocd ", allocd) -s_t[4] = fmt("Free ", free) -s_t[5] = "\nlua:\n" -s_t[6] = fmt("Used", lu * 1024) -s_t[7] = "\n\nNote that the rockbox used count is a high watermark" +s_t[2] = "Loops : " +s_t[3] = loops - 1 +s_t[4] = "\n" +s_t[5] = fmt("Used ", used) +s_t[6] = fmt("Allocd ", allocd) +s_t[7] = fmt("Free ", free) +s_t[8] = "\nlua:\n" +s_t[9] = fmt("Used", lu * 1024) +s_t[10] = "\n\nNote that the rockbox used count is a high watermark\n" rb.splash_scroller(10 * rb.HZ, table.concat(s_t)) |