Answered by:
Memory Management

Question
-
Ok here goes..... Managed code simple for with one control takes almost 20MB of memory. I know the rutine what is shown in the task manager is not acurate but it is what people will see to compare software. Then I add an undo redo feature. Then I all user to load images and edit them in memory with this same undo and redo feature. One image 20 changes we are sitting at 100MB. So I know I need to reduce the image size by storing the images compressed into memory. I do not want to lose any quality in the picture. So does anyone have any suggestions? Right now I am considering saveing it as a compressed png in a memory stream. Would this be the best way to handle it?
Thanks in advance
Saturday, April 3, 2010 12:23 PM
Answers
-
Hi Chris
If I understand your situation, you are storing each change as a new image for the entire undo/redo history.
Using this approach you will very quickly run out of memory. I suggest you store only the changes, so the history can work backwards from the current image to the original. This should use much less memory, and avoid issues with using compressed images.
Paul.
Monday, April 5, 2010 12:30 PM
All replies
-
Hi Chris
If I understand your situation, you are storing each change as a new image for the entire undo/redo history.
Using this approach you will very quickly run out of memory. I suggest you store only the changes, so the history can work backwards from the current image to the original. This should use much less memory, and avoid issues with using compressed images.
Paul.
Monday, April 5, 2010 12:30 PM -
Wow that will be very hard with the development toos that I have to figure out what pixles have changes on and image to work my way back. Is there a way I can store just a small portion of an image? and put back just that piece each time they make a change?
Thanks
Chris
Tuesday, April 6, 2010 11:27 AM -
Hi Chris
There are many ways you could approach this sort of problem.
You could store a sub image that represents the last area modified on the image, another way is to do a per pixel change storing all the pixels changed in one operation in the history, and storing the changed value and the coordinates of the pixel.
Either way the outcome is generally the same, limiting the memory usage to only what is actually changed in each step in the undo history.
Paul.
Tuesday, April 6, 2010 2:33 PM -
Any sample code of this? ThanksWednesday, April 7, 2010 11:31 PM
-
Hi Chris,
Does it matter if store the edited image on the disk in a temp folder? I think it is not easy to store each changed pixel in a stack and restore them to the image. Currently you have already chosen to store each changed image in memory, so change the code a little to store the image on disk can reduce the memory usage.
Sincerely,
Kira Qian
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!Thursday, April 8, 2010 7:58 AM -
Hi Chris,
I am writing to check the status of the issue on your side. Could you please let me know if the suggestion works for you? If you have any questions or concerns, please feel free to let me know. I will be more than happy to be of assistance.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework!Monday, April 12, 2010 9:41 AM