Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Support new HTTP API for VALGRIND. v6.0.149 v7.0.6 #4150

Merged
merged 6 commits into from
Aug 21, 2024

Conversation

winlinvip
Copy link
Member

@winlinvip winlinvip commented Aug 21, 2024

New features for valgrind:

  1. ST: Support /api/v1/valgrind for leaking check.
  2. ST: Support /api/v1/valgrind?check=full|added|changed|new|quick

To use Valgrind to detect memory leaks in SRS, even though Valgrind hooks are supported in ST, there are still many false positives. A more reasonable approach is to have Valgrind report incremental memory leaks. This way, global and static variables can be avoided, and detection can be achieved without exiting the program. Follow these steps:

  1. Compile SRS with Valgrind support: ./configure --valgrind=on && make
  2. Start SRS with memory leak detection enabled: valgrind --leak-check=full ./objs/srs -c conf/console.conf
  3. Trigger memory detection by using curl to access the API and generate calibration data. There will still be many false positives, but these can be ignored: curl http://127.0.0.1:1985/api/v1/valgrind?check=added
  4. Perform load testing or test the suspected leaking functionality, such as RTMP streaming: ffmpeg -re -i doc/source.flv -c copy -f flv rtmp://127.0.0.1/live/livestream
  5. Stop streaming and wait for SRS to clean up the Source memory, approximately 30 seconds.
  6. Perform incremental memory leak detection. The reported leaks will be very accurate at this point: curl http://127.0.0.1:1985/api/v1/valgrind?check=added

Note: To avoid interference from the HTTP request itself on Valgrind, SRS uses a separate coroutine to perform periodic checks. Therefore, after accessing the API, you may need to wait a few seconds for the detection to be triggered.


Co-authored-by: Jacob Su suzp1984@gmail.com

@winlinvip winlinvip changed the title API: Support new HTTP API for VALGRIND API: Support new HTTP API for VALGRIND. v6.0.149 v7.0.6 Aug 21, 2024
@winlinvip winlinvip added the RefinedByAI Refined by AI/GPT. label Aug 21, 2024
@winlinvip winlinvip merged commit 0d76081 into ossrs:develop Aug 21, 2024
17 checks passed
winlinvip added a commit that referenced this pull request Aug 21, 2024
New features for valgrind:

1. ST: Support /api/v1/valgrind for leaking check.
2. ST: Support /api/v1/valgrind?check=full|added|changed|new|quick

To use Valgrind to detect memory leaks in SRS, even though Valgrind
hooks are supported in ST, there are still many false positives. A more
reasonable approach is to have Valgrind report incremental memory leaks.
This way, global and static variables can be avoided, and detection can
be achieved without exiting the program. Follow these steps:

1. Compile SRS with Valgrind support: `./configure --valgrind=on &&
make`
2. Start SRS with memory leak detection enabled: `valgrind
--leak-check=full ./objs/srs -c conf/console.conf`
3. Trigger memory detection by using curl to access the API and generate
calibration data. There will still be many false positives, but these
can be ignored: `curl http://127.0.0.1:1985/api/v1/valgrind?check=added`
4. Perform load testing or test the suspected leaking functionality,
such as RTMP streaming: `ffmpeg -re -i doc/source.flv -c copy -f flv
rtmp://127.0.0.1/live/livestream`
5. Stop streaming and wait for SRS to clean up the Source memory,
approximately 30 seconds.
6. Perform incremental memory leak detection. The reported leaks will be
very accurate at this point: `curl
http://127.0.0.1:1985/api/v1/valgrind?check=added`

> Note: To avoid interference from the HTTP request itself on Valgrind,
SRS uses a separate coroutine to perform periodic checks. Therefore,
after accessing the API, you may need to wait a few seconds for the
detection to be triggered.

---------

Co-authored-by: Jacob Su <suzp1984@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RefinedByAI Refined by AI/GPT.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants