Skip to content

High memory usage / Memory leak from thumbnails with emblems - 16GB+ Memory Leak #3330

Open

Description

@mindinsomnia

Distribution

Linux Mint 21.2 Cinnamon

Package version

5.8.4

Frequency

Always

Bug description

I've identified what seems to be an issue with the way that Nemo renders emblems on file icons.

Here's some background on this. I use the Nemo Dropbox plugin that adds emblems for sync status on files, such as this one:
image

I've been having a lot of system hangs with Nemo lately so I've been investigating why and I think I've narrowed down the cause. It's the emblems that Nemo is rendering on icons. There seems to be a memory leak somewhere related to these.

Screenshot from 2023-11-26 14-44-35
Here's a screenshot of Nemo consuming 16.6GBs of memory. I achieved this by scrolling through a folder with photos in it, while using the Dropbox Nemo plugin to display the sync status of files, with thumbnail size was set to the largest setting.

The folder had 10,000 files in it, but I was able to achieve this level of memory usage before I even reached halfway through the files, if I had to guess, about 4,500 files.

(Please note, before anyone says, "split up the files", this issue can not be avoided by splitting up the images across multiple folders, the memory leak persists even after navigating away from folders! Nor is the issue specific to this plugin as I'll explain below.)

I left the folder, and spent around 30 minutes browsing other folders on my system, went away, did some stuff, came back... Nemo never unloaded the data in that time, no matter what else I did, as long as the process was open that data was never unloaded from memory.

Eventually I came back to the same folder full of photos and tested memory usage as I scrolled through it. My assumption was, the loaded data was still in memory, so memory usage shouldn't climb any higher. My assumption was wrong, it took only a minute or two for memory usage to skyrocket as it seemed to reload already generated thumbnails.

Screenshot from 2023-11-26 15-29-09
See above, Nemo now up to 28GBs. Again navigating away from the folder results in no reduction of memory consumption.

I wanted to narrow down the cause and see if I could eliminate the possibility that the issue here is the Nemo Dropbox plugin, so I turned that plugin off and closed Dropbox.

I then and took two images, gave them emblems using the Nemo Emblems plugin, and put them in a temporary folder in my Downloads folder, away from Dropbox (which is on another drive) - So Dropbox / The Nemo Dropbox plugin has no impact on the following results.

Then copy/pasted those couple of images many times until I had a folder full of thumbnails with emblems and tested scrolling through that as well.
image

image
See above, it didn't take long, after scrolling through the folder, going up a folder, back into it, scrolling through it again, and repeating that a few times, already I was up to a level of memory usage that would cause a system hang on my laptop.

What about when there's no emblems?
With no emblems, there's no issues, when browsing through folders of images without emblems I see normal memory usage (almost always under 1GB, even with folders with 10,000 images), and memory drops instantly when I navigate away from folders. The key factor here seems to be the emblems.

There seems to be a couple of issues here:

  1. This memory usage seems very high. Even for this number of thumbnails, this seems like a very high memory usage for what is just some small emblems.
  2. Nemo is not unloading something from memory. Even when I navigated to a different folder, the memory usage stayed high.
  3. Nemo doesn't even re-use what is stuck in memory. It doesn't seem like Nemo is keeping track of something that is already loaded, so it's just consuming more and more space to load the same data.
  4. This will cause a near irrecoverable system hang eventually. On the PC I used for testing, I have 64GBs of RAM, but on my laptop I "only" have 16GBs, and on my laptop I regularly experience system hangs from the combination of Nemo + Nemo Dropbox consuming so much memory that my laptop runs out of RAM.
  5. This would be probably even worse for owners of 4K resolution monitors. Assuming everything in Nemo scales with screen resolution, owners of 4K resolution monitors should have thumbnails and emblems twice the size of users of 1080p screen owners right? I only have a 1080p screen so I can't test that myself but it seems logical.

Steps to reproduce

Grab a couple of files, put emblems on them using the Nemo Emblems plugin, put them into a folder. Then copy and paste them repeatedly until you have around 2000-3000 files.

Start scrolling through the files while monitoring RAM usage with the system monitor.

If you run out of files, just go up a folder, then come back and start scrolling again.

Repeat until you see the memory leak.

Expected behavior

I expected that once a thumbnail is unloaded from memory, any emblems associated with it would be unloaded as well.

Additional information

No response

Activity

  1. changed the title [-]High memory usage / Memory leak from thumbnails with emblems[/-] [+]High memory usage / Memory leak from thumbnails with emblems - 16GB+ Memory Leak[/+] on Nov 26, 2023
  2. Jeremy7701 commented on Nov 26, 2023

    @Jeremy7701
    Contributor

    It seems likely that nemo is retaining some file metadata.
    In fact, if you had 10,000 thumbnails with emblems, occupying 20GB this would mean that your average thumbnail/emblem occupies 2MB.

    I'd be interested to know how its possible to select an emblem other than doing tediously one file at a time - without copying a file multiple times!

    BTW Do you have any swap configured, so that nemo could dump some of this wasted memory?

  3. mindinsomnia commented on Nov 27, 2023

    @mindinsomnia
    Author

    It seems likely that nemo is retaining some file metadata. In fact, if you had 10,000 thumbnails with emblems, occupying 20GB this would mean that your average thumbnail/emblem occupies 2MB.

    I'd be interested to know how its possible to select an emblem other than doing tediously one file at a time - without copying a file multiple times!

    BTW Do you have any swap configured, so that nemo could dump some of this wasted memory?

    I do yup, just the defaults for Linux Mint, so 2GBs on my laptop and desktop according to the system monitor.

  4. ret2src commented on Nov 30, 2023

    @ret2src

    I can confirm this issue on Arch Linux with Nemo 6.0.0 in a Nextcloud folder containing many images and thumbnail preview enabled. I don't know if it's related to the emblems, but there's definitely a huge memory leak somewhere. It made my whole system unresponsive today, had to force reboot because I couldn't even open a terminal emulator window or switch to another TTY.

  5. mindinsomnia commented on Nov 30, 2023

    @mindinsomnia
    Author

    Does the nextcloud folder show sync status emblems on the files?

    I can confirm this issue on Arch Linux with Nemo 6.0.0 in a Nextcloud folder containing many images and thumbnail preview enabled. I don't know if it's related to the emblems, but there's definitely a huge memory leak somewhere. It made my whole system unresponsive today, had to force reboot because I couldn't even open a terminal emulator window or switch to another TTY.

  6. ret2src commented on Dec 1, 2023

    @ret2src

    Does the nextcloud folder show sync status emblems on the files?

    Yes, it does.

    This is the memory usage with three Nemo windows open after browsing some folders with a few images:

    image

    Yesterday it ate up my whole 32 GBs (!)

  7. mindinsomnia commented on Dec 1, 2023

    @mindinsomnia
    Author

    Does the nextcloud folder show sync status emblems on the files?

    Yes, it does.

    This is the memory usage with three Nemo windows open after browsing some folders with a few images:

    image

    Yesterday it ate up my whole 32 GBs (!)

    Yeah that does sound like the same thing I'm seeing. It seems to happen with anything that adds emblems to icons. Perhaps a temporary image is being generated to composite the thumbnails with the emblems and isn't unloaded from memory?

  8. mtwebster commented on Dec 1, 2023

    @mtwebster
    Member

    I honestly can't tell the difference between emblems and no emblems here, but I can reproduce a leak.

  9. self-assigned this
    on Dec 1, 2023
  10. u2n commented on Feb 17, 2024

    @u2n

    Did the 12/15 commit fix this issue? (Thanks BTW, @mtwebster.) LMDE 6.1.76-1 (2/1/24), Nemo 6.0.2, with same symptoms when even one emblem is used, though file count is less than 50 (much lower than reported above). Eliminating all emblems returns behavior to normal.

  11. mindinsomnia commented on Feb 17, 2024

    @mindinsomnia
    Author

    From my testing it seems the issue still persists, but this issue isn't closed yet so perhaps there's more changes planned for how to address it.

  12. mtwebster commented on Feb 17, 2024

    @mtwebster
    Member

    Correct, the change I did above was a safe fix for something related that I discovered while looking at the primary issue.

    The real issue isn't going to be as simple to address (image caching problems). I'm hoping to have it fixed before the next release though.

  13. juliuspopp commented on Jun 1, 2024

    @juliuspopp

    I have the same issue, 11 GB of memory usage just for nemo while browsing picture folders and having nextcloud active.
    The issue does not arise when the owncloud module of nemo, SyncStateExtension_ownCloud+NemoPython, is deactivated.
    When I activate it (Nextcloud is running in the background) and navigate to a folder with <100 images, the RAM usage keeps increasing to 9 GB within 20 seconds.

  14. arseru commented on Jun 17, 2025

    @arseru

    The issue does not arise when the owncloud module of nemo, SyncStateExtension_ownCloud+NemoPython, is deactivated

    I have the same issue on Arch Linux with nemo v6.4.5, but reading the quote above, I'm guessing the memory leak comes from the file /usr/share/nemo-python/extensions/syncstate-Nextcloud.py (I don't know how to debug it yet), so is it maybe better to open a ticket on either nemo-extensions or nextcloud-client?

  15. 21347 commented on Mar 17, 2026

    @21347

    I found this (old) issue when Nemo 6.6.1 on Linux Mint 22.3 got OOM-Killed after filling up 48 GiB of RAM. So, I think it's still present.

    I, too, first suspected the Nexcloud plugin to be the culprit, but then I did the same tests as the 1st post suggests (creating a folder with random files in it, adding some emblems, duplicating them until I had a reasonable amount) with nextcloud plugin disabled, Nemo quickly filled up ~1GiB for around 700 Files. Unless deactivated plugins still get loaded and are allowed to mess around, I'd rule that out...

    I tried around, and can confirm that the amount of memory consumed depends on the size of the thumbnail preview.
    While that, by it self, seems no surprise, I think it might mean that the issue is related to the thumbnail images (or something linked to them - masks, emblem overlay images etc.) don't get freed.
    As scrolling around in the folder increases the memory consumption, whatever it is seems to be re-created whenever a file is scrolled into view.

    Also, the thumbnails need to be "individual", i.e. created from the file's contents / an image. "Generic" thumbnails (like for an empty text file) do not lead to any large memory consumption.

    The amount of emblems does not seem to play a large role, though: I added around 10, with largest preview size that ended up at around 3.2 MiB per file, compared to around 2.9 MiB before. Given the way I used to calculate that number is quite basic, I'm careful with that.

    Allocated memory lives process-wide - navigating away from the folder only frees a fraction of it, even if I close the window. I need to close all Nemo Windows / exit the process to free the memory, as reported earlier.

    I'll try to test that on different systems and maybe a clean VM...

  16. 21347 commented on Apr 3, 2026

    @21347

    So, I installed a new VM with Mint 22.3 and tested: same problem. Folders with emblemed images quickly fill up memory.

    I cloned nemo and built my own version to do some digging, and apparently there's two different "paths" that icon images will follow, depending on if they are should show an emblem or not

    if (emblem_icons != NULL) {

    a) "normal" one: get an icon using nemo_file_get_icon, pass that one to the caller directly
    b) "emblemed version": start with a), but then transfer that to a GEmblemedIcon, and add emblems, one by one. Then, use caching (nemo_icon_info_lookup) to store the GEmblemedIcon and the icon_info for future use, and return the icon_info to the caller.

    nemo_icon_info_lookup (GIcon *icon,

    I temporarily removed caching (nemo_icon_info_lookup does everything as it did, except creating the key and storing the reference - note that emblemed icons are not "LOADABLE"). And, well - no memory "leaks" any more (though I'd argue that it never was a "leak" in the classic way, I guess all those blocks are still held and referenced somewhere, valgrind tells something similar). Memory usage is still way higher when using the emblemed icons (about 2 times), but once I change the folder, nemo frees all memory (previously, both the GEmblemedIcon and the icon_info were kept)

    Also, what was observed in the past was, that opening the same folder again used even more memory. I guess that the caching algorithm was made to prevent just that - as far as I can see, g_icon_equal is required to return TRUE for that to work. I'm no GTK expert - how deep is the comparison there? I suppose it will not compare pixels, but rather references?

    Still, the emblemed versions of the icons take up more memory - although the resulting pixbufs are the same size; so there's more to discover :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions