California
Posts: 217
Joined: Sat Jun 06, 2015 2:33 pm

RAM usage increased after 10 days more than 10x

Tue Apr 20, 2021 10:50 am

Hello, I hope this is the right place to post this topic.
I have a python app running on RPi3B, which works normal few days, then everything become wery slow. To solve this I manage to put together small piece of code inside of the app to reboot RPi every 10th day. After research what is going on, big diference in usage of the RAM is discovered between first day and last day. Below are two screenshots where could be clearly seen the diference. So the question is: why this happend and what could be done to avoid this situation. BTW, code can't be post here becouse it's related to hardware and couldnt be run without it. Regards, Vlado

Image
Image

User avatar
topguy
Posts: 7078
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: RAM usage increased after 10 days more than 10x

Tue Apr 20, 2021 11:37 am

Code could still have been visually analyzed to look for clues about memory leakage.

https://medium.com/zendesk-engineering/ ... 24d0518774

California
Posts: 217
Joined: Sat Jun 06, 2015 2:33 pm

Re: RAM usage increased after 10 days more than 10x

Tue Apr 20, 2021 4:59 pm

Thanks for your respond, I can pack complete code and post it here if you would be so kind to check it, couse I am a little bit short for this task.

User avatar
thagrol
Posts: 4674
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: RAM usage increased after 10 days more than 10x

Tue Apr 20, 2021 6:21 pm

California wrote:
Tue Apr 20, 2021 4:59 pm
Thanks for your respond, I can pack complete code and post it here if you would be so kind to check it, couse I am a little bit short for this task.
What's your height got to do with it? :D

if you mean short of time, what makes you think anyone on here will do it for you? Especially as you haven't said how long the code is and how much payment you're offering if any. And which (human) language those screen shots are in.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
DougieLawson
Posts: 41160
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: RAM usage increased after 10 days more than 10x

Tue Apr 20, 2021 10:22 pm

thagrol wrote:
Tue Apr 20, 2021 6:21 pm
And which (human) language those screen shots are in.
Since the image is hosted on a Slovenian website, it's probably a fair assumption as to the language.

My only encounter with Slovenia was skiing at Kranska Gora (when there wasn't really enough snow on the mountain (they were doing their best to piste bash it into submission every night) and it didn't snow all week until 15 minutes after we'd handed the rental skis back into the shop). Nice people, nice place, but not high enough above MSL for decent snow.
Any language using left-hand whitespace for syntax is ridiculous

Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.

Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

California
Posts: 217
Joined: Sat Jun 06, 2015 2:33 pm

Re: RAM usage increased after 10 days more than 10x

Wed Apr 21, 2021 7:29 pm

Yes, it is Slovenian language. About RAM: obviously I was wrong when thinking about easy solution. Rebooting RPi after 10 days of operation is not so bad...
Thanks anyway,

Regards, Vlado

Heater
Posts: 17991
Joined: Tue Jul 17, 2012 3:02 pm

Re: RAM usage increased after 10 days more than 10x

Thu Apr 22, 2021 7:33 pm

California wrote:
Wed Apr 21, 2021 7:29 pm
Rebooting RPi after 10 days of operation is not so bad...
It's a solution to get one by I guess.

Perhaps it's just me but that is the kind of problem that would cause me to not sleep at night. I would be tormented by the fact that I don't really understand what my program is doing. The cause of such a memory leak would have to be found.

Oddly enough a colleague of mine has a similar memory leak problem with one of his Python programs. Everything runs fine for days, no mysterious increase of memory consumption going on. Then boom!. It uses as much memory as it can and falls over.
Memory in C++ is a leaky abstraction .

User avatar
jahboater
Posts: 6919
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: RAM usage increased after 10 days more than 10x

Thu Apr 22, 2021 7:45 pm

Heater wrote:
Thu Apr 22, 2021 7:33 pm
California wrote:
Wed Apr 21, 2021 7:29 pm
Rebooting RPi after 10 days of operation is not so bad...
Perhaps it's just me but that is the kind of problem that would cause me to not sleep at night. I would be tormented by the fact that I don't really understand what my program is doing. The cause of such a memory leak would have to be found.
+1 totally!
If you are accustomed to writing software for servers that must run for an indefinite period of time, then memory leaks must be fixed - sev 1.
Rebooting every 10 days is quite appalling.
Mind you, I did see a program on an MCU that ran to completion in a few milliseconds, and so the chip was rebooted by the 100Hz mains frequency, avoiding any long term problems :)

Try the "valgrind" tool which may help.

Or use a language like C where the memory management is explicit and dealt with by the programmer, so easily fixed.

Return to “Raspberry Pi OS”