Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted

1 solution

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.
 
Share this answer
 
Comments
akul123 24-Apr-12 1:14am    
I have already observed how much memory is used using Task Manager. When new bitmap is created then memory usage increases and when the bitmap is disposed then memory usage decreases. But when the operation is done repeatedly and Memory usage shows 1.7 GB or more then it shows the exceptions.
Bernhard Hiller 24-Apr-12 3:54am    
"when the operation is done repeatedly and Memory usage shows 1.7 GB or more": this means that you do not clean-up correctly!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900