【问题标题】:Out of memory exception issue内存不足异常问题
【发布时间】:2018-09-11 05:45:43
【问题描述】:

我随机出现内存不足异常,我正在从 AWS 下载我的项目中的大量图像。如何解决问题

[369][4/29/2011 18:32:15:343]-ERR -[ThreadId = 7916, UIFramework_ICEVisionPro_GUIExceptionHandler.LogException]-System.OutOfMemoryException: Out of memory.

   at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc)

   at System.Drawing.BufferedGraphicsContext.CreateBuffer(IntPtr src, Int32 offsetX, Int32 offsetY, Int32 width, Int32 height)

   at System.Drawing.BufferedGraphicsContext.AllocBuffer(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)

   at System.Drawing.BufferedGraphicsContext.AllocBufferInTempManager(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)

   at System.Drawing.BufferedGraphicsContext.Allocate(IntPtr targetDC, Rectangle targetRectangle)

   at System.Windows.Forms.Control.WmPaint(Message& m)

   at System.Windows.Forms.Control.WndProc(Message& m)

   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

   at System.Windows.Forms.ContainerControl.WndProc(Message& m)

   at System.Windows.Forms.UserControl.WndProc(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 

【问题讨论】:

  • 在里面添加一些代码,已经试过了..
  • how to solve the issue 取决于你如何下载它们,以及你用它们做什么
  • 使用 Glide lib 将位图设置为 imageview

标签: android performance-testing


【解决方案1】:

压缩下载的位图如下

FileOutputStream fos = new FileOutputStream(output.getPath()); myBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);

这里的 100 表示压缩以获得最高质量。

【讨论】:

  • 那没有用。将其写入磁盘。它不会压缩用于将其存储在 RAM 中以进行绘图的内存量。
猜你喜欢
  • 2010-10-05
  • 1970-01-01
  • 2010-12-21
相关资源
最近更新 更多