-
Notifications
You must be signed in to change notification settings - Fork 48
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
Cannot Allocate Memory when using Interrupts #21
Comments
Hello alindsay81, i am in a big projekt and had the same problems. the threading of pfacedigitalio is broken in pifacecommon. if you activate the listeners like you do, every event/interrupt is caching memory, this is a "i think known" memory leak. I tried to find the leak, but could not find it. this is my workaround: import pifacedigitalio as pf in_tic = [ 0, 0, 0, 0, 0, 0, 0, 0] Handle holen vom PiFacepifacedigital = pf.PiFaceDigital() Tic_in Klasse wird initialisiertclass Tic_in(threading.Thread):
#Then start the thread tic_in = Tic_in() this is much faster and the memory leak is gone. Greetings from germany, Marc |
Hi Marc, Thanks so much for this - With a few small changes it slots perfectly with the rest of my project and works exactly as it should! - CPU use was very high (85%) so i increased the sleep time to 10ms and cpu use came down to 35% - my pulse width is 50ms so 10ms cycle time is no problem for me |
Hm, I'll flag this for investigation in pifacecommon. Thanks. |
So i created a fairly simple python program counting pulses using interrupts and i tested it on the bench with a single input for a couple of days and everything seemed to work well, when i started to use it for real i had 5 inputs and the pulse frequency was a bit higher, after around 22 hours the counting would stop. When i looked into why it could see that Python3 memory use was going up and up everytime a pulse was counted. The first thing i did was to create a test program that only counted and the problem persists with the pi eventually giving the error Cannot Allocate Memory - my test code is here;
def testcount(event):
global Count1
Count1 += 1
print(Count1)
Setup the Digital IO to watch for Rising Edge only
pifacedigital = pifacedigitalio.PiFaceDigital()
listener = pifacedigitalio.InputEventListener(chip=pifacedigital)
listener.register(0, pifacedigitalio.IODIR_RISING_EDGE, testcount)
listener.activate()
Here is a screen shot of the pi back on the bench showing the memory use rising. it only rises when a pulse is received
The text was updated successfully, but these errors were encountered: