Closed spacewander closed 4 years ago
Great! There is indeed a memory leak in that situation, thank you for posting the issue. But I think the patch is incorrect because it is not actually publishing. The modified code may potentially lead to some problems. I will fix it later, thank you!
Thank you for your quick response!
Hello, the bug was fixed.
The memory pool is created in publish function in gop module without checking if stream is publishing
in live module. If stream is not publishing
(ctx->publishing == 0), the created pool will not be destroyed, memory leak occurs.
By the way, "live: already publishing" is not weird, it will always happen if configuration file as yours is used.
Thanks again for posting the issue!
When I try to do rtmp 302, I always see a weird error log
live: already publishing
in the error.log file, though the rtmp 302 works well. When stopping Nginx, sometimes I also notice a memory leak detected by ASAN:The pool is expected to be released in: https://github.com/winshining/nginx-http-flv-module/blob/aee1608d81120979db7846d211a215dade019c9e/ngx_rtmp_gop_cache_module.c#L935
My Nginx configuration is:
The http://127.0.0.1:8888/on_play will return status code 302 and redirect the client to port 1935, then server listening port 1935 will pull the rtmp stream from port 19350.
The stream is created by
ffmpeg -re -i ~/data/dump.mp4 -c copy -f flv rtmp://127.0.0.1:19350/app/1 -loglevel info
, and the client isvlc 'rtmp://127.0.0.1:19350/app/1'
.After applying patch below, the memory leak can't be detected anymore:
I am not sure if the problem is fixed totally.