Skip to content
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

Reduce icon memory usage #656

Merged
merged 5 commits into from
Sep 18, 2020
Merged

Reduce icon memory usage #656

merged 5 commits into from
Sep 18, 2020

Conversation

samuel-w
Copy link
Contributor

@samuel-w samuel-w commented Sep 18, 2020

Turns out, Vorta uses over 300 MB of RAM. The reason is super dumb.

The reason is the icons are imported as 1792 by 1792 images. Each one takes 14MB of memory. No one needs that. 128x128 uses no memory at all.

Now its about 163 MB RAM. Much better.

Before:

Line #    Mem usage    Increment   Line Contents
================================================
    83    144.2 MiB    144.2 MiB       @profile
    84                                 def set_icons(self):
    85    158.7 MiB     14.5 MiB           self.extractButton.setIcon(get_colored_icon('cloud-download'))
    86    172.6 MiB     13.9 MiB           self.mountButton.setIcon(get_colored_icon('folder-open'))
    87    184.7 MiB     12.1 MiB           self.checkButton.setIcon(get_colored_icon('check-circle'))
    88    197.1 MiB     12.4 MiB           self.deleteButton.setIcon(get_colored_icon('trash'))
    89    197.9 MiB      0.8 MiB           self.diffButton.setIcon(get_colored_icon('stream-solid'))
    90    210.0 MiB     12.1 MiB           self.pruneButton.setIcon(get_colored_icon('cut'))
    91    222.4 MiB     12.4 MiB           self.listButton.setIcon(get_colored_icon('refresh'))
    92    234.5 MiB     12.1 MiB           self.toolBox.setItemIcon(0, get_colored_icon('tasks'))
    93    246.9 MiB     12.4 MiB           self.toolBox.setItemIcon(1, get_colored_icon('cut'))

After:

Line #    Mem usage    Increment   Line Contents
================================================
    83    119.9 MiB    119.9 MiB       @profile
    84                                 def set_icons(self):
    85    119.9 MiB      0.0 MiB           self.extractButton.setIcon(get_colored_icon('cloud-download'))
    86    133.9 MiB     13.9 MiB           self.mountButton.setIcon(get_colored_icon('folder-open'))
    87    133.9 MiB      0.0 MiB           self.checkButton.setIcon(get_colored_icon('check-circle'))
    88    133.9 MiB      0.0 MiB           self.deleteButton.setIcon(get_colored_icon('trash'))
    89    133.9 MiB      0.0 MiB           self.diffButton.setIcon(get_colored_icon('stream-solid'))
    90    133.9 MiB      0.0 MiB           self.pruneButton.setIcon(get_colored_icon('cut'))
    91    133.9 MiB      0.0 MiB           self.listButton.setIcon(get_colored_icon('refresh'))
    92    133.9 MiB      0.0 MiB           self.toolBox.setItemIcon(0, get_colored_icon('tasks'))
    93    133.9 MiB      0.0 MiB           self.toolBox.setItemIcon(1, get_colored_icon('cut'))

@samuel-w samuel-w changed the title Reduce memory usage Reduce icon memory usage Sep 18, 2020
Just in case we have non-square icons
@m3nu
Copy link
Contributor

m3nu commented Sep 18, 2020

Nice find. 👍 Generally SVG should be a vector image without any fixed size. But it's possible that Qt will rasteriaze it on import.

Do you see any pixelation after this change?

@samuel-w
Copy link
Contributor Author

samuel-w commented Sep 18, 2020

Not that I can notice, but I'm using a 1080p display, might be different for 4K.

It's actually visible here: #207 (comment). That 100MB jump from sourceTab to archiveTab is due to this bug.

@m3nu
Copy link
Contributor

m3nu commented Sep 18, 2020

You are brilliant. Nice find!

@m3nu m3nu merged commit b161296 into borgbase:master Sep 18, 2020
@m3nu
Copy link
Contributor

m3nu commented Sep 18, 2020

On macOS memory went form 390 to 140 MB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants