Skip to content

Commit

Permalink
Update doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Aug 21, 2024
1 parent f32a1e5 commit ea71809
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.

```
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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报告增量的内存泄露,
这样可以避开全局和静态变量,也可以不用退出程序就可以实现检测。操作步骤如下:

Expand Down Expand Up @@ -287,6 +293,8 @@ query check=added

> Note: 为了避免HTTP请求本身对valgrind的干扰,SRS使用单独的coroutine定时检查,因此访问API后,可能需要等待几秒才会触发检测。
### Valgrind: Still Reachable

有时候,你会收到很多`still reachable`的报告,这是因为静态或全局变量,比如这个例子:

```text
Expand Down

0 comments on commit ea71809

Please sign in to comment.