-
-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The undo/redo system consumes a lot of RAM #883
Comments
An idea that comes to my mind is by writing the undo history into a file |
Launching pixelorama from the godot editor, my test: on a 6400x6400 canvas, draw 10 separate (more or less) vertical lines with the pencil tool at thickness 50. Code from my proposal: around 600MB The trick is compressing the hex data in the image, and decompressing it when that "state" needs to be restored. Line 201 in e195e32
Other specific do/undo operations could be clever, and track the methods they should apply, at least in the "do" direction, rather than storing the entire images. |
As discussed on discord, the cleaner way to handle this would be to have "proper" do/undo methods to reapply/revert changes everywhere. The assumption I'm starting from is that were For the sake of discussion, I'll write here the places where I found
because those are used everywhere to make sure the UI is refreshed properly (as far as I understand it, at least).
|
Continuing from the initial work made in #890: With all these optimizations, I think this issue can be considered resolved now. The next big RAM optimization that could be done is that empty cels still consume a lot of memory. Not entirely sure how this can be solved though, perhaps by dynamically rescaling images based on how many pixels are drawn. This system could theoretically allow for layers with different sizes, but that's a discussion for another issue. A negative side effect coming from saving compressed image data in undo/redo is that drawing on large canvases is noticeably laggier, talking about sizes like 6400x6400, at least on my machine. Perhaps a better way can be found that is both not so CPU intensive and also consumes less RAM, but again, that's probably a discussion for another issue. These changes I made are for the v1.0 branch, but I will also port them to v0.11.4 soon. |
Pixelorama version:
v0.11.1-dev, happens in all previous versions as well
OS/device including version:
opneSUSE Tumbleweed, but occurs on all operating systems and hardware
Issue description:
The undo/redo system stores each change the user makes to the cel data (by drawing, applying effects etc) as separate
Image
objects for each undo state. For example, let's say we have a 6400x6400 project with a single cel. This alone consumes 6400x6400x4 ~= 163.84MB of memory. Drawing a single pixel, will store another 6400x6400 to memory via the undo/redo system, thus increasing the memory usage with another ~163MB. This is extremely inefficient, since only a single pixel has been changed. A workaround to clear the undo history is to either close and restart Pixelorama, or close that project, and the memory will be freed.Ideas and proposals on how the system can be improved are welcome!
Steps to reproduce:
Follow the example above, and have a system activity/task manager utility open to measure Pixelorama's memory usage.
The text was updated successfully, but these errors were encountered: