ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
24.7k stars 5.28k forks source link

Source: The memory leak seems still exist #4096

Closed tonyye2018 closed 1 week ago

tonyye2018 commented 1 week ago

The memory issue with SRS still appears to persist. I use RTMP to push streams to SRS, and then play them using WebRTC. After playing for a while, I close the stream, then push and play again, only to close it once more. Version: 6.0 develop branch 2024.6.18 this is my test result: unit is KB Startup memory: SRS 19032. datetime play 16 streams close all streams 13:58 77624 53152 14:03 79229 79220 14:06 95260 95260 14:13 96260 96260 14:18 97256 97256 14:28 98428 98428 14:35 99500 99500 14:42 100768 100768 14:53 101780 101900 14:59 104476 104476 15:33 107744 107744

TRANS_BY_GPT4

winlinvip commented 1 week ago

What's your SRS config?

tonyye2018 commented 1 week ago

I use the rtmp2rtc.conf or srs.conf which enable rtmp_to_rtc.

http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}

http_api {
    enabled         on;
    listen          1985;
}
stats {
    network         0;
}
rtc_server {
    enabled on;
    listen 8000; # UDP port
    # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate
    candidate $CANDIDATE;
}

vhost __defaultVhost__ {
    rtc {
        enabled     on;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc
        rtmp_to_rtc on;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp
        rtc_to_rtmp on;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
}
or srs.conf
listen              1935;
max_connections     1000;
srs_log_tank        file;
#srs_log_file        ./objs/srs.log;
daemon              on;
http_api {
    enabled         on;
    listen          1985;
}
http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}
rtc_server {
    enabled on;
    listen 8000; # UDP port
    # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate
    candidate $CANDIDATE;
}
vhost __defaultVhost__ {
    hls {
        enabled         on;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
    rtc {
        enabled     on;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc
        rtmp_to_rtc on;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp
        rtc_to_rtmp off;
    }

    play{
        gop_cache_max_frames 2500;
    }
}
tonyye2018 commented 1 week ago

I use the version which you merged newest code on morning. I get the same result.From the srs.log, I found "free rtc source id=[4t2o11ll]", it seems rtc source had been freed. But the memory is still growing.

winlinvip commented 1 week ago

Memory growth does not necessarily indicate a leak; it could be due to system caching, among other things. You can conduct tests for over an hour, and if the increase persists, then it is likely a leak.

TRANS_BY_GPT4