single_day 2017-11-29 17:00 采纳率: 0%
浏览 1382
已结题

C#winform资源释放问题

C#在调用Aspose.Cells.dll把Excel表格生成图片时内存占用率会越来越高是什么问题?

 Workbook book = new Workbook(Application.StartupPath + @"\Config\excel.xlsx");
            Worksheet sheet = book.Worksheets[0];

            sheet.PageSetup.LeftMargin = 0;
            sheet.PageSetup.RightMargin = 0;
            sheet.PageSetup.BottomMargin = 0;
            sheet.PageSetup.TopMargin = 0;

            ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
            imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Bmp;

            imgOptions.OnePagePerSheet = true;
            imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;

            SheetRender sr = new SheetRender(sheet, imgOptions);
            sr.ToImage(0, Application.StartupPath + @"\Config\Excel.bmp");

这段代码是放在timer里面定时循环执行的!

  • 写回答

10条回答

  • threenewbee 2017-11-29 17:01
    关注

    不排除aspose有内存泄漏,用using把Workbook、SheetRender都包括进来,或者用dispose方法释放下。

    评论

报告相同问题?

悬赏问题

  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件