Skip to content

would calling spidev.SpiDev() function repeatedly cause memory leak #139

@jamcinnes2

Description

@jamcinnes2

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug reportneeds infoRequires more information or research

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions