RPi 3B memory leakage using OSMC wifi adapter

I’ve documented elsewhere issues I’ve had with SSH to my RPi 3B. It turns out my problem was the Pi was running out of memory. We spent a great deal of time and space in the aforementioned thread trying to diagnose the problem. The prevailing opinion at the end of that thread was that I needed to connect via ethernet instead of wifi and to try a fresh installation of OSMC on a new SD card. I’ve done both of those things and am posting my initial results here.

I sought and received special dispensation from my wife to run an ethernet cable across the living room floor so I could connect the pi using ethernet instead of wifi. Bottom line: It looks to me like wifi is indeed the problem or at least a significant component of the problem. Below is a graph of available memory reported by free -m for 74 time periods spaced 30 minutes apart, so the results span 74/2 = 37 hours.

I rebooted the pi every morning at 0300 so it wouldn’t run out of memory. These reboots occurred at periods 17 and 65. The first 33 observations were using wifi, the remaining were using ethernet. I began using OSMC to watch recorded TV programs via NextPVR at periods 5 and 50.

There were two periods between reboots using wifi and ethernet. While using wifi, the pi leaked 5.6 MB per 30 minute period during the first of these and 6.05 for the second. That’s about 12 MB per hour of memory leakage.

On ethernet, the pi leaked 2.64 MB per 30 minute period for one and .6 MB per 30 minute period for the other. The average of those two is about 1.6 MB per 30 minute period.

Another thing that stands out is the pi leaked memory even while I wasn’t using OSMC using wifi, whereas memory available remained constant while connected with ethernet while I wasn’t using OSMC.

Using wifi or ethernet, available memory dropped noticeably whenever I began using OSMC to stream content, which makes sense. What doesn’t make sense is that memory was never fully reclaimed when I stopped using OSMC. Perhaps I should have started and stopped using OSMC multiple times between reboots to see if it needed more memory or was content with what it already had.

I bought a new SD card and did a fresh install of OSMC on it to see whether anything about the card could be causing my memory problems. So far, I’ve only loaded and enabled NextPVR, installed cron, and made the changes to /etc/connman.conf and /boot/config.txt to support the OSMC wifi dongle and to enter my video license codes. I’ve not tried connecting SMB shares yet. I’ll wait until I have some memory observations before I do that.

As always, I look forward to any thoughts or ideas.

Thank you.

Are you referring to the 802.11ac WiFi adapter?
There should be a new driver in the 5.10 kernel for v19 which will behave better.

I’m surprised we haven’t had other reports of this however.

Sam

I believe so, Sam. I’ve usually referred to it as the OSMC 5G dongle.

I had earlier reasoned that I should not upgrade to v19 due to other issues, but if the driver will improve things, then I will. Is there a way to update the driver short of taking the next release?

Thanks!

Unfortunately not – the new kernel has significant changes needed to facilitate playback changes in Kodi v19. It could be upgraded to in isolation but I’m not sure what the implications of playback on v18 would be.

Sam

OK. Thanks Sam. I’ll look forward to the next release and will update to it, despite the misgivings I’ve developed on reading the v19 thread.

I wondered about this myself. I guess there are only a few of us left who use the OSMC dongle.

I may go ahead and buy a 3B+ to get around this problem. Would that make sense?

Thanks again.

I can show you how to install the 5.10 kernel later – but I haven’t got around to testing the new driver with it yet. It should work out of the box, but a firmware file may be missing at the moment.

This is not my area of expertise but I know the linux memory subsystem will be doing all sorts of things in the background to cache files and move stuff in and out of memory so I’d imagine it will be near impossible to compare runs side by side to identify cause of the memory usage. I fear you could spend a lot of time with no clear answer.

As a reference point, we have at home a 3B (Ethernet) and 3B+ (2G WiFi) with OSMC on them and they run for months without reboot. Both have SSH active. I’ve never knowingly experienced an out of memory issue on either of them.

I think the problem is with connecting at 5G, and it appears you’re using 2.4G on both your 3B and 3B+. Is that correct? Do you use the OSMC 5G dongle on either of them?

This problem just started for me a couple months ago. My Pi would run out of memory in 2-3 days and became inaccessible via SSH. I had to “pull the plug” to reboot it.

Sorry to be thick, Sam. I think you’re saying there’s a good chance that the 3B+, with its onboard 5G wifi, will suffer the same problems I’m having with the OSMC dongle. Do I understand correctly?

Thanks for the help.

No – sorry, wasn’t clear. I mean that we may be able to resolve the issue with this adapter with the kernel update

Sam

Got it, Sam. Thanks. Again, sorry to be thick. I’ll stand by for additional advice on a kernel update whenever you think it makes sense.

3B connected to ethernet. 3B+ uses Wifi (using internal chip). Don’t use the OSMC dongle on them. I’d guess 2G vs 5G wouldn’t affect anything though.

That sounds annoying!

Saw in your other thread that power line doesn’t work for you. If you want to use ethernet, as an another idea, have you thought about a wall plug-in wifi extender with a built-in ethernet port?

@djbloc I appreciate your interest and suggestions. Thank you.

My problem only occurs with wifi. Ethernet works OK, at least that’s what the data seems to be telling me. Your results are actually encouraging to me. They suggest that if I bought a 3B+ and used its onboard wifi, I wouldn’t have the memory problem. 2.4G is unusable here in my neighborhood. It’s just too crowded.

Indeed! Something happened with my setup a couple months ago. It was not a problem before then.

Powerline works on most circuits but it doesn’t work in the outlets near my TV and related gear, probably due to too much interference. If I plug into an outlet about 10 feet away (on another circuit) I get pretty good ethernet bandwidth. If I plugged an extender into an outlet near my TV and ran ethernet from it to Pi from there, it would probably work, but that would require spending some bucks on an extender (or similar piece of gear) that worked with 5G. Last time I checked, those weren’t cheap, but I’ll check again.

That graph looks pretty good. It’s always going to fluctuate but the trend sits around the 500MB mark. So, referring to memory fluctuations as “leakage” is probably unwarranted in this case.

Since you have a second SD card, it would be sensible to stick with the plan and see if the problem persists on the new card/installation. Only then should you try the 5.10 kernel, which is very easy to install (and will be even easier when @sam_nazarko fixes the depmod error :slight_smile: ).

Fair enough. :grin: I was wondering when someone was going to “complain” about my offensive language. I used to manage IT groups back in the day and know how stirred up programmers would get when you told them their code was leaking memory. It’s like calling their baby ugly! But it always got their attention!

Nevertheless, if you decide not to reboot every night and extend the trend line out to, say, “leaking” 10 MB per hour, then if you start with 500, you use all your memory up in between 2 and 3 days, which has been my experience. No offense to anyone, but you shouldn’t have to reboot a system that often to keep it running. Others here don’t have to do that.

To your broader point, though, I will stick with the plan and see what happens with the new installation. I’ll report back once I have useful information. I’m also going to refrain from installing any more add-ons or accessing my SMB shares until I gauge what happens with “just” NextPVR running.

Thanks again for your help and support, and for sticking with me though this experience.

No worries. I missed this critical bit:

Are you just using the free command to check the memory usage? If so you might want to look at /proc/meminfo

cat /proc/meminfo

that will show you much more about what’s using memory, like the file cache.

Yes I am. @dillthedog advised me to use /proc/meminfo in the future but I got a bit lazy and used the simple free -m command. I’ll have a look.

Back in the other thread, we eventually concluded that the memory problem lay in the kernel, and further information about running processes would not likely be helpful.

I’ll withhold further opinion until we see some results with the new SD card. I must say, though, that preliminary results suggest little to no improvement over the “old” SD card when running wifi.

Thanks.

That was fixed some time ago – 5.10 now lives in staging repository.

1 Like

A quick update: I’ve been trying to collect relevant data about the leakage rate using the new SD card and fresh installation but I’m being stymied by a failure of wifi to reconnect after my 0300 reboot. I’ve posted about that problem here.

Once I get wifi to reconnect automatically after rebooting, I’ll post results pertinent to my memory leakage problem.

Thanks for your continued patience and support.