This python library https://github.com/chandrawi/LoRaRF-Python uses spidev. I'm getting a memory leak using this LoRaRF library on an rpi Zero 2. Tracemalloc shows that the culprit is this function in the LoRaRF library. I suspect calling the spidev constructor over and over for every transfer is the problem. Do you think?
def transfer(self, buf: Iterable) -> tuple:
spi = spidev.SpiDev()
spi.open(self.bus, self.cs)
spi.lsbfirst = False
spi.mode = 0
spi.max_speed_hz = self.speed
ret = spi.xfer2(buf)
spi.close()
return ret