winlin

refine the memory watcher.

@@ -961,6 +961,12 @@ void SrsSource::dispose() @@ -961,6 +961,12 @@ void SrsSource::dispose()
961 hls->dispose(); 961 hls->dispose();
962 #endif 962 #endif
963 963
  964 + // cleaup the cached packets.
  965 + srs_freep(cache_metadata);
  966 + srs_freep(cache_sh_video);
  967 + srs_freep(cache_sh_audio);
  968 +
  969 + // cleanup the gop cache.
964 gop_cache->dispose(); 970 gop_cache->dispose();
965 } 971 }
966 972
@@ -74,7 +74,7 @@ void srs_memory_report() @@ -74,7 +74,7 @@ void srs_memory_report()
74 std::map<void*, SrsMemoryObject*>::iterator it; 74 std::map<void*, SrsMemoryObject*>::iterator it;
75 for (it = _srs_ptrs.begin(); it != _srs_ptrs.end(); ++it) { 75 for (it = _srs_ptrs.begin(); it != _srs_ptrs.end(); ++it) {
76 SrsMemoryObject* obj = it->second; 76 SrsMemoryObject* obj = it->second;
77 - printf(" %s: %#"PRIx64", %dKB\n", obj->category.c_str(), (int64_t)obj->ptr, obj->size / 1000); 77 + printf(" %s: %#"PRIx64", %dB\n", obj->category.c_str(), (int64_t)obj->ptr, obj->size);
78 total += obj->size; 78 total += obj->size;
79 } 79 }
80 80
@@ -192,8 +192,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -192,8 +192,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
192 * whether enable the special memory watcher. 192 * whether enable the special memory watcher.
193 * which used for memory leak debug and hurts performance. 193 * which used for memory leak debug and hurts performance.
194 */ 194 */
195 -#undef SRS_MEM_WATCH  
196 #define SRS_MEM_WATCH 195 #define SRS_MEM_WATCH
  196 +#undef SRS_MEM_WATCH
197 197
198 #endif 198 #endif
199 199
@@ -211,6 +211,11 @@ void check_macro_features() @@ -211,6 +211,11 @@ void check_macro_features()
211 #warning "current branch is not stable, please use stable branch instead." 211 #warning "current branch is not stable, please use stable branch instead."
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 +
  215 +#ifdef SRS_MEM_WATCH
  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.");
  218 +#endif
214 219
215 #if defined(SRS_AUTO_STREAM_CASTER) 220 #if defined(SRS_AUTO_STREAM_CASTER)
216 #warning "stream caster is experiment feature." 221 #warning "stream caster is experiment feature."