Memory leak while using libvlc imem module

This forum is about all development around libVLC.
vlad-29
New Cone
New Cone
Posts: 7
Joined: 17 Nov 2016 11:40

Memory leak while using libvlc imem module

Postby vlad-29 » 13 Dec 2016 08:21

Hello, I have memory leak when I play or broadcast video from my camera with imem module.
I used this code:

Code: Select all

int myImemGetCallback(void *data, const char *cookie, int64_t *dts, int64_t *pts, unsigned *flags, size_t * bufferSize, void ** buffer) { int ret = 0; int size = globalsize; if(!bufferinit) *buffer = malloc(size);// malloc once memcpy(*buffer, data, size); *dts = globaldts; globaldts = globaldts + 33333; *pts = globalpts; globalpts = globalpts + 33333; *bufferSize = size; return ret; } int myImemReleaseCallback(void *data, const char *cookie, size_t bufferSize, void * buffer) { int ret = 0; return ret; }
My vlc arguments:

Code: Select all

vlc_args[0] = "-vvvvv"; vlc_args[1] = (char*)calloc(200, 1); sprintf(vlc_args[1], "--imem-get=%ld", myImemGetCallback); vlc_args[2] = (char*)calloc(200, 1); sprintf(vlc_args[2], "--imem-release=%ld", myImemReleaseCallback); vlc_args[3] = (char*)calloc(200, 1); sprintf(vlc_args[3], "--imem-cat=2"); //CAT 1 == AUDIO vlc_args[4] = (char*)calloc(200, 1); sprintf(vlc_args[4], "--imem-data=%ld", buffertobroadcast);/** my context custom data to be passed callbacks **/ vlc_args[5] = "--imem-id=0"; vlc_args[6] = (char*)calloc(200, 1); sprintf(vlc_args[6], "--imem-codec=RV24"); //CODEC, format of the data passed to vlc in the buffers vlc_args[7] = (char*)calloc(200, 1); sprintf(vlc_args[7], "--imem-width=640"); vlc_args[8] = (char*)calloc(200, 1); sprintf(vlc_args[8], "--imem-height=360"); vlc_args[9] = (char*)calloc(200, 1); sprintf(vlc_args[9], "--imem-channels=%d", mNumInputs); //number of channels vlc_args[10] = (char *)calloc(200, 1); sprintf(vlc_args[10], "--imem-samplerate=%d", mSampleFreq); //sample frequency vlc_args[11] = (char *)calloc(200, 1); sprintf(vlc_args[11], "--imem-fps=25.000000"); //sample frequency
My broadcast arguments:

Code: Select all

libvlc_vlm_add_broadcast(inst, "stream", "imem://", "#transcode{vcodec=h264,vb=3000,fps=25,scale=1,acodec=a52,ab=128,channels=2,samplerate=44100}:rtp{mux=ts,dst=127.0.0.1}", 0, NULL, 1, 0);
There is no memory leak while broadcasting or playing in window are not executed.
Also the message "late buffer for mux input" appear constantly.
imem works well and I can watch the video from camera and stream but memory leaks very fast. I don't see where it can leak in my code, maybe I miss something?

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Memory leak while using libvlc imem module

Postby Jean-Baptiste Kempf » 27 Dec 2016 11:49

Memleaks should be debugged with valgrind traces.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

vlad-29
New Cone
New Cone
Posts: 7
Joined: 17 Nov 2016 11:40

Re: Memory leak while using libvlc imem module

Postby vlad-29 » 06 Feb 2017 11:56

I found the problem. This is unnecessary and makes memory leak. There is no need to allocate memory in imem-get function.

Code: Select all

if(!bufferinit) *buffer = malloc(size);// malloc once memcpy(*buffer, data, size);


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 12 guests