WPFDevelopersOrg / WPFDevelopers

🎉 Welcome to follow the "WPFDevelopers" public account! This is a sample project we share daily, covering WPF's basic controls and custom control libraries. The project will be continuously updated, welcome to give us ⭐️
MIT License
1.5k stars 240 forks source link

截屏内存无限制上涨的问题 #77

Closed 862256261 closed 1 month ago

862256261 commented 8 months ago

执行截屏后内存没有自动释放,请解决一下吧谢谢

yanjinhuagood commented 8 months ago

GC垃圾回收器会自动进行内存管理,并在需要时释放不再使用的对象。

862256261 commented 8 months ago

并没有回收啊,内存蹭蹭上涨

862256261 commented 8 months ago

1704785832226 1704785858207 1704785880857 这分别是初次打开程序的内存,截图完成第一次的内存,截图完成第二次的内存

yanjinhuagood commented 8 months ago

正在解决中。

yanjinhuagood commented 8 months ago
  1. 请使用最新Nuget
  2. 下载体验
yanjinhuagood commented 8 months ago

示例代码:

 private void ButtonExt_Click(object sender, RoutedEventArgs e)
 {
     var screenCaptureExt = new ScreenCaptureExt();
     screenCaptureExt.SnapCanceled += ScreenCaptureExt_SnapCanceled;
     screenCaptureExt.SnapCompleted += ScreenCaptureExt_SnapCompleted;
 }
 private void ScreenCaptureExt_SnapCompleted(System.Windows.Media.Imaging.BitmapSource bitmap)
 {
 }

 private void ScreenCaptureExt_SnapCanceled()
 {
     Message.Push($"{DateTime.Now} 取消截图",MessageBoxImage.Information);
 }
yanjinhuagood commented 8 months ago

https://github.com/WPFDevelopersOrg/WPFDevelopers/wiki/ScreenCapture