内存泄漏问题

This commit is contained in:
lijun 2025-01-18 15:32:10 +08:00
parent b8b6cb838c
commit 66e341e938
2 changed files with 7 additions and 4 deletions

View File

@ -175,7 +175,7 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, device_id int) {
if err != nil { if err != nil {
log.Printf("img encode err:%v", err) log.Printf("img encode err:%v", err)
worker.SetRedisSetRemove(online_conn_key, con_id) worker.SetRedisSetRemove(online_conn_key, con_id)
goto end break
} }
buf1 := buf.GetBytes() buf1 := buf.GetBytes()
@ -183,7 +183,7 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, device_id int) {
if err2 != nil { if err2 != nil {
log.Printf("send message to client err:%v", err2) log.Printf("send message to client err:%v", err2)
worker.SetRedisSetRemove(online_conn_key, con_id) worker.SetRedisSetRemove(online_conn_key, con_id)
goto end break
} }
c = count c = count
err4 := img.Close() err4 := img.Close()
@ -198,7 +198,9 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, device_id int) {
if err != nil { if err != nil {
log.Printf("Connection check failed:%v", err) log.Printf("Connection check failed:%v", err)
worker.SetRedisSetRemove(online_conn_key, con_id) worker.SetRedisSetRemove(online_conn_key, con_id)
goto end break
} else {
log.Printf("Connection check success")
} }
} }
} }
@ -206,7 +208,6 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, device_id int) {
t_count++ t_count++
} }
end:
// 查看是否还有其他连接,没有则设置 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)

View File

@ -167,6 +167,8 @@ func GetDeviceCurrentFrameV3(deviceId int) (gocv.Mat, int) {
} }
//查看地址 //查看地址
log.Printf("frame:%p,Device1CurrentFrame:%p,Device50CurrentFrame:%p\n", &frame, &Device1CurrentFrame, &Device50CurrentFrame) log.Printf("frame:%p,Device1CurrentFrame:%p,Device50CurrentFrame:%p\n", &frame, &Device1CurrentFrame, &Device50CurrentFrame)
//查看帧状态
log.Printf("frame:%v,Device1CurrentFrame:%v,Device50CurrentFrame:%v\n", frame.Empty(), Device1CurrentFrame.Empty(), Device50CurrentFrame.Empty())
return frame, frame_count return frame, frame_count
} }
func GetDeviceCurrentFrame(deviceId int) (gocv.Mat, int) { func GetDeviceCurrentFrame(deviceId int) (gocv.Mat, int) {