From ea71809f5043443803d2f23d84b5666667b3ac6c Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 21 Aug 2024 12:19:19 +0800 Subject: [PATCH] Update doc. --- .../current/doc/performance.md | 8 ++++++++ .../current/doc/performance.md | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/performance.md b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/performance.md index f43a64c..414d3d1 100644 --- a/i18n/en-us/docusaurus-plugin-content-docs/current/doc/performance.md +++ b/i18n/en-us/docusaurus-plugin-content-docs/current/doc/performance.md @@ -247,6 +247,10 @@ killall -2 srs ## VALGRIND +Valgrind is a powerful tool for memory leak and other issue. + +### Valgrind: Memcheck + SRS3+ also supports valgrind. ``` @@ -257,6 +261,8 @@ valgrind --leak-check=full --show-leak-kinds=all ./objs/srs -c conf/console.conf > Remark: For HTTP valgrind API, you should upgrade your SRS to required version, see [#4149](https://github.com/ossrs/srs/pull/4149). +### Valgrind: Incremental Memory Leak Detection + 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 @@ -286,6 +292,8 @@ query 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. +### Valgrind: Still Reachable + Sometimes, you will receive the `still reachable` report for static or global variables, like this example: ```text diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/performance.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/performance.md index fcaf88b..a6648ae 100644 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/performance.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/doc/performance.md @@ -250,7 +250,11 @@ killall -2 srs ## VALGRIND -VALGRIND是大名鼎鼎的内存分析工具,SRS3之后支持了。SRS3之前,因为使用了ST,需要给ST打PATCH才能用。 +VALGRIND是大名鼎鼎的内存分析工具,SRS3之后支持了。 + +### Valgrind: Memcheck + +SRS3之前,因为使用了ST,需要给ST打PATCH才能用。 ``` valgrind --leak-check=full --show-leak-kinds=all ./objs/srs -c conf/console.conf @@ -260,6 +264,8 @@ valgrind --leak-check=full --show-leak-kinds=all ./objs/srs -c conf/console.conf > Remark: SRS需要升级到对应版本,才能支持HTTP valgrind API,具体参考 [#4149](https://github.com/ossrs/srs/pull/4149)。 +### Valgrind: Incremental Memory Leak Detection + 使用valgrind检测SRS内存泄露时,尽管在ST中支持了valgrind的hook,还是有大量的误报信息。比较合理的是让valgrind报告增量的内存泄露, 这样可以避开全局和静态变量,也可以不用退出程序就可以实现检测。操作步骤如下: @@ -287,6 +293,8 @@ query check=added > Note: 为了避免HTTP请求本身对valgrind的干扰,SRS使用单独的coroutine定时检查,因此访问API后,可能需要等待几秒才会触发检测。 +### Valgrind: Still Reachable + 有时候,你会收到很多`still reachable`的报告,这是因为静态或全局变量,比如这个例子: ```text