LibVLCSharp长时间播放视频时非托管内存持续增长问题排查
LibVLCSharp 长时间运行非托管内存持续增长问题排查
我正在使用LibVLCSharp开发一款需长时间运行的视频播放应用,遇到了非托管内存随时间稳步增长的问题——播放过程中非托管内存占用持续上升,怀疑此问题与我通过SetVideoCallback实现视频播放的方式相关。

上图展示了37小时内的内存变化曲线,清晰呈现出内存持续增长的趋势。尽管尝试了多种诊断方法,我仍无法定位内存泄漏的根源。
以下是我的视频播放设置简化代码:
private IntPtr Lock(IntPtr opaque, IntPtr planes, VLCStream stream) { Debug.WriteLine("[Debug] callback-Lock"); stream.CurrentTime = DateTime.UtcNow.ToLocalTime(); Marshal.WriteIntPtr(planes, stream.Handle.AddrOfPinnedObject()); return IntPtr.Zero; } private void Display(IntPtr opaque, IntPtr picture, VLCStream stream) { try { if (_isPauseStream) { return; } if (!stream.PlayerPrepared) { return; } TimeSpan timeDifference = stream.CurrentTime - stream.PrevTime; double millisecondsDifference = timeDifference.TotalMilliseconds; if (millisecondsDifference < stream.Config.StreamDurationTime) { return; } if (OnReceiveFrame != null) { stream.FrameID = stream.FrameID + 1; RaiseOnReceiveFrame(stream.Config.FrameWidth, stream.Config.FrameHeight, stream.Config.FrameChannels, stream.Buffer, stream.Config.Idx, stream.FrameID, stream.CurrentTime); Debug.WriteLine($"[Debug] callback-Display"); } stream.PrevTime = stream.CurrentTime; } catch (Exception ex) { Debug.WriteLine($"[Error] Display Callback Exception: {ex.Message}"); } }
请问是否有人了解LibVLCSharp在视频播放时非托管内存持续增长的原因?SetVideoCallback是否存在已知问题,或是有哪些内存管理最佳实践可用于长时间运行的应用?
我已尝试多种方法清理非托管内存泄漏,目前正尝试基于libvlc开发C++库。
内容的提问来源于stack exchange,提问作者남기준
相关产品推荐
相关产品推荐

