nginx-ts-module icon indicating copy to clipboard operation
nginx-ts-module copied to clipboard

Possible memory leak

Open vicentroca opened this issue 7 years ago • 8 comments

I'm using this module and I see that the nginx process is eating memory without stop. ¿any idea how to debug this problem? Thank you ;)

vicentroca avatar Feb 16 '18 15:02 vicentroca

Can you elaborate on this? What is configuration do you have? Can you simplify the configuration and find a minimum config that eats the memory.

arut avatar Apr 06 '18 13:04 arut

Hi @arut, I'm resuming this as I have the same issue. I've built this module (commit ef2f874d) with nginx 1.14.0:

[root@bf5203f01065 sbin]# ./nginx -V nginx version: nginx/1.14.0 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) configure arguments: --with-debug --add-module=/root/ts-module/nginx-ts-module/ --prefix=/root/ts-module/nginx

Then I've run it with valgrind and massif:

[root@bf5203f01065 sbin]# valgrind --tool=massif ./nginx &

According to massif there's seems to be an issue with memory allocated by the ngx_http_request_body_save_filter.

I've pushed a ts stream to nginx with the following command:

ffmpeg -re -i joined.mp4 -bsf:v h264_mp4toannexb -c copy -f mpegts http://127.0.0.1:8080/publish/fauno

I'm attaching nginx.conf and a couple of massif logs (massif.out.28 was produced without the ffmpeg -re option).

ts-module.tar.gz

Any help would be appreciated.

utu2016 avatar May 21 '19 10:05 utu2016

After looking into nginx code I think the problem is with chain links in rb->bufs which should be freed before setting rb->bufs = NULL as follows:

for (cl = rb->bufs; cl;) { tl = cl; cl = cl->next; ngx_free_chain(r->pool, tl); }

utu2016 avatar May 23 '19 11:05 utu2016

i have same issue after 3-5 day run nginx-ts eat memory 20-30Gb do you have fix of this problem ?

micron10 avatar Dec 02 '19 22:12 micron10

After looking into nginx code I think the problem is with chain links in rb->bufs which should be freed before setting rb->bufs = NULL as follows:

for (cl = rb->bufs; cl;) { tl = cl; cl = cl->next; ngx_free_chain(r->pool, tl); }

Did it fix the issue for you @utu2016 ? I'm also seeing crazy RAM usage.

mattpepin avatar Dec 12 '19 20:12 mattpepin

news?

masterkain avatar Feb 15 '20 12:02 masterkain

Any news ?

micron10 avatar Mar 04 '20 03:03 micron10

Is it freed after stream end? Is it specific to HLS or DASH?

AleXoundOS avatar Aug 08 '21 19:08 AleXoundOS