Unfreed memory when playing images

This forum is about all development around libVLC.
Kwigon
New Cone
New Cone
Posts: 5
Joined: 26 Jul 2021 11:31

Unfreed memory when playing images

Postby Kwigon » 15 Dec 2021 12:04

Hello,

I am trying to create a player which will play an endless slideshow of both images and videos. It should run for an unlimited time, therefore, memory usage is important to me.

I would like to ask what is the correct way to free memory after playing media. According to https://wiki.videolan.org/LibVLC_Tutorial/, calling

Code: Select all

libvlc_media_release(m);
on the media is enough. However, this seems to resolve the memory when playing videos but not for images. If I repeatedly play an image, the memory consumptions increases each play.

From my understanding the release function can not free the memory itself as the medium is played after being released in the tutorial. Is there something I'm missing?

I am using python binding for libVLC (https://github.com/oaubert/python-vlc). I appreciate any help I can get, thank you in advance. Here's a minimal code to reproduce the issue:

Code: Select all

import vlc import time media_player = vlc.MediaPlayer() media = vlc.Media("large_image.jpg") media_player.set_media(media) media.release() media_player.play() time.sleep(10) media_player.set_media(media) media.release() media_player.play() time.sleep(10) media_player.set_media(media) media.release() media_player.play() time.sleep(10) media_player.set_media(media) media.release() media_player.play() time.sleep(10) media_player.set_media(media) media.release() media_player.play() time.sleep(10) media = vlc.Media("video.mp4") media_player.set_media(media) media.release() media_player.play() time.sleep(10) media_player.set_media(media) media.release() media_player.play() time.sleep(10) media_player.set_media(media) media.release() media_player.play() time.sleep(10) media_player.set_media(media) media.release() media_player.play() time.sleep(10)

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Unfreed memory when playing images

Postby Rémi Denis-Courmont » 15 Dec 2021 19:55

Most memory is held by the media player, not the media, so you need to release the player.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

ssbmaccom
Cone that earned his stripes
Cone that earned his stripes
Posts: 184
Joined: 26 Nov 2015 15:21
Operating System: Mac OS, iOS, tvOS

Re: Unfreed memory when playing images

Postby ssbmaccom » 15 Jan 2022 17:15

I was doing something similar (also in Python) on Raspberry Pi machines.
I haven't seen this issue - but indeed, the Pi will usually shutdown late at night and restart in morning hours (to reduce energy use and light pollution at times, when we do not expect anyone passing by the POI), so I may have not experienced that.
But I will test run my implementation to check for this.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 30 guests