内存泄漏解决测试

This commit is contained in:
lijun 2025-01-22 14:28:04 +08:00
parent 1110ca1b9c
commit 02a7738c49
1 changed files with 7 additions and 1 deletions

View File

@ -213,10 +213,11 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, device_id int) {
//定时器,发送计数器 //定时器,发送计数器
t_count := 0 t_count := 0
t := 0 t := 0
img := gocv.NewMat()
//计算帧率 //计算帧率
for { for {
//从service获取当前帧 //从service获取当前帧
img, c := service.GetDeviceCurrentFrameV3(device_id) c := service.GetDeviceCurrentFrameV2(&img, device_id)
if c != count { if c != count {
if c == -1 { if c == -1 {
log.Printf("device:%d get frame err!", device_id) log.Printf("device:%d get frame err!", device_id)
@ -269,6 +270,11 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, device_id int) {
t_count++ t_count++
} }
err5 := img.Close()
if err5 != nil {
log.Printf("img close err:%v", err5)
}
// 查看是否还有其他连接,没有则设置 is_play 为 0 // 查看是否还有其他连接,没有则设置 is_play 为 0
if worker.IsContainKey(online_conn_key) == false { if worker.IsContainKey(online_conn_key) == false {
worker.SetRedisWithExpire(strconv.Itoa(device_id)+"_is_play", "1", time.Minute*5) worker.SetRedisWithExpire(strconv.Itoa(device_id)+"_is_play", "1", time.Minute*5)