正在显示
8 个修改的文件
包含
22 行增加
和
17 行删除
@@ -136,6 +136,12 @@ else | @@ -136,6 +136,12 @@ else | ||
136 | echo "#undef SRS_AUTO_SSL" >> $SRS_AUTO_HEADERS_H | 136 | echo "#undef SRS_AUTO_SSL" >> $SRS_AUTO_HEADERS_H |
137 | fi | 137 | fi |
138 | 138 | ||
139 | +if [ $SRS_MEM_WATCH = YES ]; then | ||
140 | + echo "#define SRS_AUTO_MEM_WATCH" >> $SRS_AUTO_HEADERS_H | ||
141 | +else | ||
142 | + echo "#undef SRS_AUTO_MEM_WATCH" >> $SRS_AUTO_HEADERS_H | ||
143 | +fi | ||
144 | + | ||
139 | # whether compile ffmpeg tool | 145 | # whether compile ffmpeg tool |
140 | if [ $SRS_FFMPEG_TOOL = YES ]; then | 146 | if [ $SRS_FFMPEG_TOOL = YES ]; then |
141 | echo "#define SRS_AUTO_FFMPEG_TOOL" >> $SRS_AUTO_HEADERS_H | 147 | echo "#define SRS_AUTO_FFMPEG_TOOL" >> $SRS_AUTO_HEADERS_H |
@@ -60,6 +60,9 @@ SRS_LOG_TRACE=RESERVED | @@ -60,6 +60,9 @@ SRS_LOG_TRACE=RESERVED | ||
60 | # experts | 60 | # experts |
61 | # donot compile ssl, use system ssl(-lssl) if required. | 61 | # donot compile ssl, use system ssl(-lssl) if required. |
62 | SRS_USE_SYS_SSL=NO | 62 | SRS_USE_SYS_SSL=NO |
63 | +# enable memory watch, detect memory leak, | ||
64 | +# similar to gmc, should disable in release version for hurts performance. | ||
65 | +SRS_MEM_WATCH=NO | ||
63 | # export the srs-librtmp to specified project, NO to disable it. | 66 | # export the srs-librtmp to specified project, NO to disable it. |
64 | SRS_EXPORT_LIBRTMP_PROJECT=NO | 67 | SRS_EXPORT_LIBRTMP_PROJECT=NO |
65 | # export the srs-librtmp to a single .h and .c, NO to disable it. | 68 | # export the srs-librtmp to a single .h and .c, NO to disable it. |
@@ -195,6 +198,7 @@ Conflicts: | @@ -195,6 +198,7 @@ Conflicts: | ||
195 | 198 | ||
196 | Experts: | 199 | Experts: |
197 | --use-sys-ssl donot compile ssl, use system ssl(-lssl) if required. | 200 | --use-sys-ssl donot compile ssl, use system ssl(-lssl) if required. |
201 | + --memory-watch enable memory watch to detect memory leaking(hurts performance). | ||
198 | --export-librtmp-project=<path> export srs-librtmp to specified project in path. | 202 | --export-librtmp-project=<path> export srs-librtmp to specified project in path. |
199 | --export-librtmp-single=<path> export srs-librtmp to a single file(.h+.cpp) in path. | 203 | --export-librtmp-single=<path> export srs-librtmp to a single file(.h+.cpp) in path. |
200 | 204 | ||
@@ -283,6 +287,7 @@ function parse_user_option() { | @@ -283,6 +287,7 @@ function parse_user_option() { | ||
283 | --full) SRS_ENABLE_ALL=YES ;; | 287 | --full) SRS_ENABLE_ALL=YES ;; |
284 | 288 | ||
285 | --use-sys-ssl) SRS_USE_SYS_SSL=YES ;; | 289 | --use-sys-ssl) SRS_USE_SYS_SSL=YES ;; |
290 | + --memory-watch) SRS_MEM_WATCH=YES ;; | ||
286 | --export-librtmp-project) SRS_EXPORT_LIBRTMP_PROJECT=${value} ;; | 291 | --export-librtmp-project) SRS_EXPORT_LIBRTMP_PROJECT=${value} ;; |
287 | --export-librtmp-single) SRS_EXPORT_LIBRTMP_SINGLE=${value} ;; | 292 | --export-librtmp-single) SRS_EXPORT_LIBRTMP_SINGLE=${value} ;; |
288 | 293 |
@@ -569,7 +569,7 @@ void SrsServer::dispose() | @@ -569,7 +569,7 @@ void SrsServer::dispose() | ||
569 | st_usleep(100 * 1000); | 569 | st_usleep(100 * 1000); |
570 | } | 570 | } |
571 | 571 | ||
572 | -#ifdef SRS_MEM_WATCH | 572 | +#ifdef SRS_AUTO_MEM_WATCH |
573 | srs_memory_report(); | 573 | srs_memory_report(); |
574 | #endif | 574 | #endif |
575 | } | 575 | } |
@@ -893,7 +893,7 @@ void SrsServer::on_signal(int signo) | @@ -893,7 +893,7 @@ void SrsServer::on_signal(int signo) | ||
893 | signal_gmc_stop = true; | 893 | signal_gmc_stop = true; |
894 | #else | 894 | #else |
895 | srs_trace("user terminate program"); | 895 | srs_trace("user terminate program"); |
896 | -#ifdef SRS_MEM_WATCH | 896 | +#ifdef SRS_AUTO_MEM_WATCH |
897 | srs_memory_report(); | 897 | srs_memory_report(); |
898 | #endif | 898 | #endif |
899 | exit(0); | 899 | exit(0); |
@@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
23 | 23 | ||
24 | #include <srs_core_mem_watch.hpp> | 24 | #include <srs_core_mem_watch.hpp> |
25 | 25 | ||
26 | -#ifdef SRS_MEM_WATCH | 26 | +#ifdef SRS_AUTO_MEM_WATCH |
27 | 27 | ||
28 | #include <map> | 28 | #include <map> |
29 | #include <stdio.h> | 29 | #include <stdio.h> |
@@ -68,7 +68,7 @@ void srs_memory_unwatch(void* ptr) | @@ -68,7 +68,7 @@ void srs_memory_unwatch(void* ptr) | ||
68 | 68 | ||
69 | void srs_memory_report() | 69 | void srs_memory_report() |
70 | { | 70 | { |
71 | - printf("srs memory leak report:\n"); | 71 | + printf("srs memory watch leak report:\n"); |
72 | 72 | ||
73 | int total = 0; | 73 | int total = 0; |
74 | std::map<void*, SrsMemoryObject*>::iterator it; | 74 | std::map<void*, SrsMemoryObject*>::iterator it; |
@@ -79,6 +79,7 @@ void srs_memory_report() | @@ -79,6 +79,7 @@ void srs_memory_report() | ||
79 | } | 79 | } |
80 | 80 | ||
81 | printf("%d objects leak %dKB.\n", (int)_srs_ptrs.size(), total / 1024); | 81 | printf("%d objects leak %dKB.\n", (int)_srs_ptrs.size(), total / 1024); |
82 | + printf("@remark use script to cleanup for memory watch: ./etc/init.d/srs stop\n"); | ||
82 | } | 83 | } |
83 | 84 | ||
84 | #endif | 85 | #endif |
@@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
30 | 30 | ||
31 | #include <srs_core.hpp> | 31 | #include <srs_core.hpp> |
32 | 32 | ||
33 | -#ifdef SRS_MEM_WATCH | 33 | +#ifdef SRS_AUTO_MEM_WATCH |
34 | 34 | ||
35 | #include <string> | 35 | #include <string> |
36 | 36 |
@@ -174,7 +174,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -174,7 +174,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
174 | * to force the server to send smaller tcp packet. | 174 | * to force the server to send smaller tcp packet. |
175 | * @see https://github.com/simple-rtmp-server/srs/issues/320 | 175 | * @see https://github.com/simple-rtmp-server/srs/issues/320 |
176 | * @remark undef it to auto calc it by merged write sleep ms. | 176 | * @remark undef it to auto calc it by merged write sleep ms. |
177 | -* @remark only apply it when SRS_PERF_MW_SO_RCVBUF is defined. | 177 | +* @remark only apply it when SRS_PERF_MW_SO_SNDBUF is defined. |
178 | */ | 178 | */ |
179 | #ifdef SRS_PERF_MW_SO_SNDBUF | 179 | #ifdef SRS_PERF_MW_SO_SNDBUF |
180 | //#define SRS_PERF_SO_SNDBUF_SIZE 1024 | 180 | //#define SRS_PERF_SO_SNDBUF_SIZE 1024 |
@@ -188,12 +188,5 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -188,12 +188,5 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
188 | #undef SRS_PERF_FAST_FLV_ENCODER | 188 | #undef SRS_PERF_FAST_FLV_ENCODER |
189 | #define SRS_PERF_FAST_FLV_ENCODER | 189 | #define SRS_PERF_FAST_FLV_ENCODER |
190 | 190 | ||
191 | -/** | ||
192 | - * whether enable the special memory watcher. | ||
193 | - * which used for memory leak debug and hurts performance. | ||
194 | - */ | ||
195 | -#define SRS_MEM_WATCH | ||
196 | -#undef SRS_MEM_WATCH | ||
197 | - | ||
198 | #endif | 191 | #endif |
199 | 192 |
@@ -160,7 +160,7 @@ SrsCommonMessage::SrsCommonMessage() | @@ -160,7 +160,7 @@ SrsCommonMessage::SrsCommonMessage() | ||
160 | 160 | ||
161 | SrsCommonMessage::~SrsCommonMessage() | 161 | SrsCommonMessage::~SrsCommonMessage() |
162 | { | 162 | { |
163 | -#ifdef SRS_MEM_WATCH | 163 | +#ifdef SRS_AUTO_MEM_WATCH |
164 | srs_memory_unwatch(payload); | 164 | srs_memory_unwatch(payload); |
165 | #endif | 165 | #endif |
166 | srs_freep(payload); | 166 | srs_freep(payload); |
@@ -173,7 +173,7 @@ void SrsCommonMessage::create_payload(int size) | @@ -173,7 +173,7 @@ void SrsCommonMessage::create_payload(int size) | ||
173 | payload = new char[size]; | 173 | payload = new char[size]; |
174 | srs_verbose("create payload for RTMP message. size=%d", size); | 174 | srs_verbose("create payload for RTMP message. size=%d", size); |
175 | 175 | ||
176 | -#ifdef SRS_MEM_WATCH | 176 | +#ifdef SRS_AUTO_MEM_WATCH |
177 | srs_memory_watch(payload, "RTMP.msg.payload", size); | 177 | srs_memory_watch(payload, "RTMP.msg.payload", size); |
178 | #endif | 178 | #endif |
179 | } | 179 | } |
@@ -187,7 +187,7 @@ SrsSharedPtrMessage::SrsSharedPtrPayload::SrsSharedPtrPayload() | @@ -187,7 +187,7 @@ SrsSharedPtrMessage::SrsSharedPtrPayload::SrsSharedPtrPayload() | ||
187 | 187 | ||
188 | SrsSharedPtrMessage::SrsSharedPtrPayload::~SrsSharedPtrPayload() | 188 | SrsSharedPtrMessage::SrsSharedPtrPayload::~SrsSharedPtrPayload() |
189 | { | 189 | { |
190 | -#ifdef SRS_MEM_WATCH | 190 | +#ifdef SRS_AUTO_MEM_WATCH |
191 | srs_memory_unwatch(payload); | 191 | srs_memory_unwatch(payload); |
192 | #endif | 192 | #endif |
193 | srs_freep(payload); | 193 | srs_freep(payload); |
@@ -212,7 +212,7 @@ void check_macro_features() | @@ -212,7 +212,7 @@ void check_macro_features() | ||
212 | srs_warn("SRS %s is not stable, please use stable branch %s instead", RTMP_SIG_SRS_VERSION, VERSION_STABLE_BRANCH); | 212 | srs_warn("SRS %s is not stable, please use stable branch %s instead", RTMP_SIG_SRS_VERSION, VERSION_STABLE_BRANCH); |
213 | #endif | 213 | #endif |
214 | 214 | ||
215 | -#ifdef SRS_MEM_WATCH | 215 | +#ifdef SRS_AUTO_MEM_WATCH |
216 | #warning "srs memory watcher will hurts performance. user should kill by SIGTERM or init.d script." | 216 | #warning "srs memory watcher will hurts performance. user should kill by SIGTERM or init.d script." |
217 | srs_warn("srs memory watcher will hurts performance. user should kill by SIGTERM or init.d script."); | 217 | srs_warn("srs memory watcher will hurts performance. user should kill by SIGTERM or init.d script."); |
218 | #endif | 218 | #endif |
-
请 注册 或 登录 后发表评论