Page 1 of 1

Unfreed memory when playing images

Posted: 15 Dec 2021 12:04
by Kwigon
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)

Re: Unfreed memory when playing images

Posted: 15 Dec 2021 19:55
by RĂ©mi Denis-Courmont
Most memory is held by the media player, not the media, so you need to release the player.

Re: Unfreed memory when playing images

Posted: 15 Jan 2022 17:15
by ssbmaccom
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.