内存不足异常 [英] Out of memory exceptions

查看:130
本文介绍了内存不足异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天以来,我一直在尝试优化用c#4.0编写的图像处理程序(裁剪,旋转,更改亮度和撤消).从谷歌那里获得建议我已经在许多方面优化了代码.最初,没有处理掉一些一次性物品,这就是显示异常的原因.但是我已经尝试处置所有一次性物品.程序仍然显示内存不足异常.这就是为什么我上传程序以获得更好的解决方案的原因.请从链接下载

http://www.box.com/s/8eab0f3669ec4d79e3fc

我的机器配置:Core 2 Duo,2 GB RAM,Windows XP Service Pack 3

请按照以下步骤操作:

运行程序

加载多张图像(至少6张)(每张图像为3.5 MB或更大)

双击图像,裁剪(右键单击)并保存.对其他图像执行相同的操作.走着瞧吧.它将显示内存不足异常.

如果重复(一次又一次)执行任何其他操作(例如更改亮度),则它还会显示内存不足异常.

我很期待您的答复.

解决方案

您应该购买并使用内存分析器来查看如何使用内存...

但是首先,您可以大致了解使用任务管理器使用多少内存,并一次执行一个操作,并记下应用程序使用了多少内存.


For some days I have been trying to optimize an image processing program (cropping, rotate, changing brightness and undo) written in c# 4.0. Getting suggestions from google I have optimized the code in many ways. At first some disposable objects hadn’t been disposed that’s why exception was shown. But I have tried to dispose all disposable objects. Still the program is showing out of memory exceptions. That’s why I have uploaded the program for better solutions. Please download from the link

http://www.box.com/s/8eab0f3669ec4d79e3fc

My machine configuration: Core 2 Duo, 2 GB RAM, Windows XP service pack 3

Follow the steps:

Run the program

Load multiple images (at least 6) (each image is 3.5 MB or greater)

Double click on an image, crop (right click) and save. Do the same operation for other images. See what happens. It will show out of memory exceptions.

If any other operations (e.g. changing brightness) is done repeatedly (again and again) then it also shows out of memory exception.

I am eagerly waiting for your reply.

解决方案

You should buy and use a memory profiler to see how you utilize your memory...

But at first, you can have a rough idea on how much memory you use by using Task Manager and do one operation at a time and take note of how much memory is used by your application.


这篇关于内存不足异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆