-
Notifications
You must be signed in to change notification settings - Fork 56
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
Support for "cleaning" the images from ram #28
Comments
It seems like swww would sometimes clean the ram when its usage get too high |
Yes, this is annoying, I agree, but unfortunately, I don't think there is anything we can do about it. Rust frees the img vector once it goes out of scope, meaning the memory will be given back to the OS, but it is up to it, the OS, to actually reclaim it. I looked up into this some time ago and there was basically nothing realistic we could go. See, for example, this SO question for more details. Writing a bunch of code for this is not something I am currently interested in. It could potentially involve looking into the image crate's internal, which would greatly increase our maintenance burden (since we would have to always keep track of changes in image crate's internal code and adapt accordingly). In my experience, RAM usage will rarely go beyond 250MB, even when cycling through many images in a directory. Ultimately, I decided this was good enough. However, it is indeed very unfortunate, since during development I managed to reduce the memory usage to just ~35MB even with a 450 frames 1920x1080 gif. But the problem was, I would change something completely unrelated to the memory usage, and it would pretty much double, because that would cause a cascade of changes that would eventually lead to the OS taking longer to reclaim memory. I will leave this open for now, because it might be that there is a way, and I am just not aware of it. Regardless, I am afraid you should think of this as a very long-term goal.
For the record, how much is this "too high" threshold for you? |
It sometimes cleans it at 200MB, but sometimes it would clean it at about 350MB instead |
Update: I have thought of something that might improve the situation. Currently, we send the image's filename to the daemon, and open and decode it there. We could instead open and decode the image in the client, send it to the daemon via socket, and just play the transition / animation there. This would mean the daemon won't have to allocate memory to decode the image. I don't know in practice if this will make a huge difference, but we can try it. Also, in the beginning of development I decided to make everything one huge binary because it was convenient, but we could also make memory usage go down by separating the client and the daemon in two separate programs. |
I am about to merge PR #57. If it's not too much trouble, could you try out the Note that, after compiling, you will have to run the daemon manually: |
Works pretty well! |
Currently(at least from what I've observed), swww will put every image you load into ram, which is not great since I change my wallpapers quite commonly
I hope that there could be a subcommand that will "clean" everything except the currently loaded wallpaper
Maybe sth like
cleancache
The text was updated successfully, but these errors were encountered: