How does the "Source use" info works?

Hi guys!
Here is the case…

  1. New file was created. It is empty, and by default, it shows 3 layers in the source use.
  2. Copying into this file some designs. In my example, the source use shows 190K layers and 0.43 RAM used.
  3. Deleting all designs. Source use show 154K layers and 0.37 RAM used.

Questions:

  1. Why does the empty file shows 3 layers?
  2. Why does after deleting everything in the file, source use still shows a big amount of layers and RAM used?

Please explain to me how source use info works, so I can correctly apply its logic for my projects and files organizations.

Thank you.

So I caveat all this by saying I don’t work for Figma and so my knowledge of all this is based on my personal research, because “Resource Use” is not officially documented.

  1. An empty file isn’t really empty. Figma file structure (as documented in the plugins API) is based on nodes, and an empty file actually has three nodes (a.k.a. layers):

• The document (the root of all other layers)
• A page (every file starts with one and you can’t delete it)
• A prototype background (which in the API counts as a page)

I think that’s how they get to 3 layers on an empty file. But this is a guess.

  1. This is also more of a guess but based on my research…

Deleting everything in the file doesn’t actually delete everything (or to be more precise, it doesn’t clear the memory used by Figma). That is because Figma manages its undo/redo stack by keeping things in memory. That’s how Figma stays super responsive when you delete everything and then undo it.

What I haven’t figured out is the mechanism that triggers memory reduction. It seems to have many factors in play (e.g. multiplayer, connection to various libraries, saving a version, etc.) What I do know is that after some period of time, you should see the memory usage drop at some point after you close and reopen the file after deleting everything in it.

But again, I’ve only based this on my personal research (trying to troubleshoot large Figma files on iPad) and I remember an engineer at Figma telling me not to read too deeply into the Resource Use panel stats. Especially since it is not documented.

Thank you @ntfromchicago
Your research seems pretty logical to me.