A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1--[[
2 __________ __ ___.
3 Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 \/ \/ \/ \/ \/
8 $Id$
9 Example Lua Memory Use
10 Copyright (C) 2020 William Wilgus
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
15 This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 KIND, either express or implied.
17]]--
18
19local a = {}
20loops = 1 --global
21
22local function alloc_tables(loops)
23 for i=1,loops do a[i] = {{}}; local b = {} end
24 return true
25end
26
27local ret
28local status = true
29rb.lcd_putsxy(0, 0, "memchk loops : ")
30while (status and loops < 1000)
31do
32 rb.lcd_putsxy(0, 20, loops)
33 rb.lcd_update()
34 alloc_tables(loops)
35 -- do call protected to catch OOM condition
36 status, ret = pcall(alloc_tables, loops * 1000)
37 loops = loops + 1
38 _G.loops = loops
39end
40
41local used, allocd, free = rb.mem_stats()
42local lu = collectgarbage("count")
43local fmt = function(t, v) return string.format("%s: %d Kb\n", t, v /1024) end
44
45-- this is how lua recommends to concat strings rather than ..
46local s_t = {}
47s_t[1] = "rockbox:\n"
48s_t[2] = "Loops : "
49s_t[3] = loops - 1
50s_t[4] = "\n"
51s_t[5] = fmt("Used ", used)
52s_t[6] = fmt("Allocd ", allocd)
53s_t[7] = fmt("Free ", free)
54s_t[8] = "\nlua:\n"
55s_t[9] = fmt("Used", lu * 1024)
56s_t[10] = "\n\nNote that the rockbox used count is a high watermark\n"
57rb.splash_scroller(10 * rb.HZ, table.concat(s_t))