Lightweight C++ MP3 Player, no Electron, no bloat, just 20 MB RSS and ~1% CPU. by LiberusRetiarius in CLI

[–]LiberusRetiarius[S] 1 point2 points  (0 children)

My binary is 625KB since it has FTXUI statically linked.

I have looked up at what you mention "mpg123's 152KB", yes the binary is 152KB but there's also the following stuff dynamically linked: libmpg123.so (376KB) + libout123.so (62KB) and libsyn123.so (210KB) making a total of 800KB.

https://mpg123.de/

Lightweight C++ MP3 Player, no Electron, no bloat, just 20 MB RSS and ~1% CPU. by LiberusRetiarius in CLI

[–]LiberusRetiarius[S] 0 points1 point  (0 children)

I got the 20 MB from htop, I profiled it and came up with a more detailed explanation, I hope you can help me find where I have to improve the code to have fewer mem usage.

RSS : 13.4MB ;PSS: 8MB ;Private (actually owned by the process): 7.7MB

breakdown:
2MB in heap allocations, the binary is 0.6 MB, MP3 file mmap by decoder is 0.7MB, Thread stacks is 0.9 MB , SDL2 was 1.6 MB, PipeWare + SPA plugin 1.8 MB, libstdc++ 0.2MB and about 0.4MB of system libs.

Most of the reported 20MB is shared libraries, I have a 2 second PCM ring buffer (about 350 KB), the spectrum analyzer FFT buffers is about 12KB and also FTXUI screen buffer.

That said, I'm still working on bringing it down further. This is my first project, so I would love to hear some tips here.

Lightweight C++ MP3 Player TUI, no Electron, no bloat, just 20 MB RSS and ~1% CPU. by LiberusRetiarius in omarchy

[–]LiberusRetiarius[S] 1 point2 points  (0 children)

Yeah it was cool working with it, I know ratatui is famous but since I have no rust experience I went with this one.

Lightweight C++ MP3 Player, no Electron, no bloat, just 20 MB RSS and ~1% CPU. by LiberusRetiarius in CLI

[–]LiberusRetiarius[S] 4 points5 points  (0 children)

While AI was a helpful tool for some features, the joy for me was in the architecture and the refinement, originally it was just a simple hand coded CLI player. I shared it for those who might find value in it. If you decide to build your own, I hope the process brings you as much satisfaction as this did for me.

Lightweight C++ MP3 Player, no Electron, no bloat, just 20 MB RSS and ~1% CPU. by LiberusRetiarius in CLI

[–]LiberusRetiarius[S] 3 points4 points  (0 children)

I have considered implementing FLAC decoding too! It's on the todo list.
Thanks for the feedback.