Skip to content

Memory Leak on Raspberry Pi 3B when playing audio files #283

@tomhaines

Description

@tomhaines

When using pyglet.media to play a playlist of music MP3s on a Raspberry Pi 3B, memory usage continually increases until system starts thrashing

OS: Raspbian 10
Python: 3.7.3
Pyglet: 1.5.7
FFMPEG: 4.1.6-1~deb10u1+rpt2

The following code reproduces the error. It reads a list of MP3's from a directory of about 30 files each about 2-3 minutes long. The program initially consumes 420MB, but grows to 1.98GB by the time the system becomes unresponsive

The following code was used to reproduce the issue consistently

import pyglet
import os

path = '/path/to/directory/containing/mp3s'

pool = []
for root, dirs, files in os.walk(path, followlinks = True) :
  for name in files :
    pool.append(os.path.join(root, name))

player = pyglet.media.Player()

def queue_next() :
  s = pool.pop(0)
  print("Queueing: %s" % (s))
  player.queue(pyglet.media.load(s))
  pool.append(s) #put the item back on the end of the playlist so we never run out of songs to play

def on_eos() :
  player.next_source()
  queue_next()

player.on_eos = on_eos

queue_next()
queue_next()
player.play()

window = pyglet.window.Window(100,100,)

pyglet.app.run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions