Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ws2811_init failed: Out of memory #390

Open
robertf26 opened this issue Jan 17, 2020 · 7 comments
Open

ws2811_init failed: Out of memory #390

robertf26 opened this issue Jan 17, 2020 · 7 comments

Comments

@robertf26
Copy link

Hi,
I've been driving a WS2812B strip (300LEDs) successfully with a Raspi 1B (512MB RAM) Raspbian Stretch without GUI for a few years with this software.
Recently I added new software to my Pi and noticed that I can send LED signals initially, but after long uptimes of the Pi (between a few hours and a few days) I get: ws2811_init failed: Out of memory
In such a situation free -m looks like this:

              total        used        free      shared  buff/cache   available
Mem:            480         340          40           5          99          87
Swap:            99          18          81

Only a reboot fixes this.
Now I have been trying to increase the RAM available to Raspbian by reducing the VRAM to a minimum of 16MB since I have no GUI. But somehow it seems that it made things worse.
Now I skimmed the source code and saw a reference to VideoCore and was wondering wether this program actually uses VRAM and that reducing such memory was counterproductive. It would be great if someone could answer as I barely understand C code.
Sadly I cannot upgrade my Pi as I have a kernel module which will only work with single core CPUs.

@Gadgetoid
Copy link
Collaborator

I'm fairly sure that rpi_ws281x doesn't use VRAM at all. The out-of-memory exception is probably due to a memory leak somewhere in either this library or some other related code.

Judging by the error being on ws2811_init I'm guessing you're running a script periodically (crontab?)? Since init should only be called once.

@jgarff
Copy link
Owner

jgarff commented Jan 17, 2020 via email

@robertf26
Copy link
Author

Thank you for the replies! I will further investigate where the memory leak comes from when I have more time. Meanwhile a nightly cronjob to reboot the Pi does the job.

@zethdubois
Copy link

Hi, I have a similar issue. 5 minute increment cronjob changes output to neopixels on GPIO.
The cronjob invokes a shell script that then calls a circuit python script to change the lights.

In the log files I find this occurs after two days of running:
RuntimeError: ws2811_init failed with code -2 (Out of memory)

@robertf26 did you come up with any leads?

@Xartrick
Copy link
Contributor

Hi, I have a similar issue. 5 minute increment cronjob changes output to neopixels on GPIO.
The cronjob invokes a shell script that then calls a circuit python script to change the lights.

In the log files I find this occurs after two days of running:
RuntimeError: ws2811_init failed with code -2 (Out of memory)

@robertf26 did you come up with any leads?

Do you call ws2811_fini at then end of your script?

@zethdubois
Copy link

Hi, I have a similar issue. 5 minute increment cronjob changes output to neopixels on GPIO.
The cronjob invokes a shell script that then calls a circuit python script to change the lights.
In the log files I find this occurs after two days of running:
RuntimeError: ws2811_init failed with code -2 (Out of memory)
@robertf26 did you come up with any leads?

Do you call ws2811_fini at then end of your script?

Sorry, not used to catching notifications on Github.

Thanks for your comment.

I'm using the Adafuit CircuitPython NeoPixel libraries.
https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel

My python script imports: neopixel and RPi.GPIO

I don't issue any commands directly to ws2811, and I don't see any code for ws2811 in the repo.

I looked for examples of ws2811_fini and found some python that does in fact initialize and finalize like you say, but it also has an instantiated object to call it. Like:

resp = ws.ws2811_init(leds)
.
[later]
.
ws.ws2811_fini(leds)

I did clone this repo [ws281x] but don't remember what step of my installation asked for that, or how I use it. My assumption is that the adafruit library must require it? I'm out of my depth here.

Eventually I put a daily reboot order in my crontab as a hacky work around. The reboot happens in time to clear the memory leak.

What would you suggest?

@lynolamero
Copy link

Thank you for the replies! I will further investigate where the memory leak comes from when I have more time. Meanwhile a nightly cronjob to reboot the Pi does the job.

Will you share with us the code to do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants