GliderGeek / pocket2rm

get articles from read-later platform pocket to the remarkable paper tablet
MIT License
184 stars 15 forks source link

High memory usage #20

Closed jrmaingo closed 2 years ago

jrmaingo commented 2 years ago

Thanks for making this tool! It works well on my RM2 but I noticed that the memory usage seems excessive for a fairly simple program so I thought we could collect ideas on how to improve this.

I've attached a snapshot of top as an example I saw. My device finished syncing 10 articles and then I checked top so I wonder if the memory is not free'd up after the sync finishes. Thoughts?

Mem: 279832K used, 747832K free, 10780K shrd, 6092K buff, 101740K cached
CPU:   0% usr   0% sys   0% nic 100% idle   0% io   0% irq   0% sirq
Load average: 0.28 0.13 0.08 3/111 635
  PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
  191     1 root     S     779m  78%   0% /home/root/pocket2rm-reload.arm
  254     1 root     S     396m  39%   0% /usr/bin/xochitl --system
  192     1 root     S     126m  13%   0% rm2fb-server
  241     1 root     S    65480   6%   0% /opt/bin/remux
  194     1 root     S    43288   4%   0% /usr/bin/sync --service
  133     1 root     S    29024   3%   0% /lib/systemd/systemd-journald
  184     1 systemd- S    19552   2%   0% /lib/systemd/systemd-timesyncd
  134     1 root     S    12200   1%   0% /lib/systemd/systemd-udevd
  187     1 root     S    12068   1%   0% /usr/bin/crashuploader --path /home/root/
  331     1 root     S    12032   1%   0% /usr/bin/qmdns-responder
    1     0 root     S    11684   1%   0% {systemd} /sbin/init
  140     1 systemd- S    10688   1%   0% /lib/systemd/systemd-networkd
  211     1 root     S    10004   1%   0% /lib/systemd/systemd-logind
  132     1 root     S     7596   1%   0% /usr/sbin/haveged -w 1024 -v 1 --Foreground
  273     1 root     S     7532   1%   0% /usr/sbin/wpa_supplicant -u
  188     1 messageb S     4084   0%   0% /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-act
  190     1 root     S     3924   0%   0% /sbin/agetty -o -p -- \u --noclear tty1 linux
  449   448 root     S     3180   0%   0% -sh
  621   620 root     S     3180   0%   0% -sh
  186     1 root     S     2740   0%   0% /usr/sbin/ifplugd -n -i usb0
  635   621 root     R     2740   0%   0% top
  204     1 root     S     2672   0%   0% /usr/sbin/dhcpcd -4 -b --master wlan0
  448     1 root     S     2592   0%   0% /usr/sbin/dropbear -i -r /etc/dropbear/dropbear_rsa_host_key -B
  620     1 root     S     2592   0%   0% /usr/sbin/dropbear -i -r /etc/dropbear/dropbear_rsa_host_key -B
  193     1 root     S     1876   0%   0% /sbin/agetty -8 -L ttymxc0 115200 xterm
   21     2 root     IW       0   0%   0% [kworker/0:1-eve]
  117     2 root     IW<      0   0%   0% [kworker/1:2H-kb]
   94     2 root     IW<      0   0%   0% [kworker/0:1H-mm]
   89     2 root     IW       0   0%   0% [kworker/1:3-eve]
  156     2 root     IW<      0   0%   0% [kworker/1:3H-kb]
   97     2 root     IW       0   0%   0% [kworker/1:5-eve]
  100     2 root     IW       0   0%   0% [kworker/0:2-eve]
  401     2 root     IW       0   0%   0% [kworker/u4:3-ev]
   83     2 root     SW       0   0%   0% [irq/74-2-0024]
  404     2 root     IW       0   0%   0% [kworker/u4:6-ev]
^C  9     2 root     SW       0   0%   0% [ksoftirqd/0]
jonaustin commented 2 years ago

This was bugging me as well; apparently golang just uses a lot of virtual memory (doesn't really affect actual real memory usage though)

from the faq:

 The Go memory allocator reserves a large region of virtual memory as an arena for allocations. This virtual memory is local to the specific Go process; the reservation does not deprive other processes of memory. 

If you look at the memory usage with something that shows RES memory usage (e.g. htop if you have opkg on your remarkable), it's more like 10KB :)

image

Refs:

jrmaingo commented 2 years ago

Thanks for the reply! I'll close this issue for now then