Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak using Win2D CanvasDrawingSession #974

Open
KaranocaVe opened this issue Dec 8, 2024 · 0 comments
Open

Memory Leak using Win2D CanvasDrawingSession #974

KaranocaVe opened this issue Dec 8, 2024 · 0 comments

Comments

@KaranocaVe
Copy link

private async void DisplayMap() { var renderPixel = _drawingManager.GetTarget().GetPixelBytes(); // 获取渲染目标 using (var image = SoftwareBitmap.CreateCopyFromBuffer(renderPixel.AsBuffer(), BitmapPixelFormat.Bgra8, _canvasWidth, _canvasHeight, BitmapAlphaMode.Premultiplied)) // 创建软件位图 { var source = new SoftwareBitmapSource(); // 创建软件位图源 await source.SetBitmapAsync(image); // 异步设置位图 ImageBox.Source = source; // 设置图像框的源 } renderPixel= null; // 释放渲染目标 }

This function identifies a severe memory leak in the GetPixelBytes function during execution. A useful insight is that my code frequently creates and destructs RenderTarget instances, which may contribute to the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant