YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
13 stars 5 forks source link

Performance: Global Search for a very frequently-used small string causes possible memory leak #5870

Open gnysek opened 2 weeks ago

gnysek commented 2 weeks ago

Description

When doing global search (Ctrl+Shift+F) for one letter, IDE takes a lot of memory (proportional to size of project). In my case, where I have 300 scripts, searching for "a" takes around +800 MB. However, it seems that IDE isn't freeing this memory until another search is performed (or after some time when GC happens), and even if, only 80-90% of memory is freed. Some amount stays reserved forever.

Steps To Reproduce

  1. Start GM and download/create a new copy of the Platformer template, save the project as normal, then close GM
  2. Start GM again and open that project
  3. Observe you will be showing as using 200MB (maybe slightly less) of RAM in Task Manager
  4. Search for "e" and observe the RAM amount rises to around 220MB
  5. Scroll the entire list of search results until you reach the bottom (mousewheel or scrollbar, does not matter)
  6. Observe you're now said to be using a constant 275MB-ish
  7. Wait, remove focus from GM, etc., and observe that 275MB stays there
  8. Close search&replace, clear the search results window, then collapse the bottom dock
  9. Observe another immediate small RAM increase which does go back down again after a short delay - however, you're still left at 275MB-ish

Which version of GameMaker are you reporting this issue for?

IDE v2024.4.0.137 Runtime v2024.4.0.168

Which operating system(s) are you seeing the problem on?

Windows 10.0.22631.0

514148c4-6cd6-4647-a247-5091a17a3b87

YYDan commented 2 weeks ago

So far, I am only seeing a very modest 10-15MB when I do my first search, so your project must be truly massive or there is some other step required. I only see around 2-3MB each time thereafter (if even that - many searches don't add anything on for me).

As you say, repeating a search for the same string doesn't seem to cause any change.

I also see a further increase each time I scroll down through the results list - although, again, this is 1-2 MB as I scroll through all 793 search matches for "e" in the project I am using.

However, yes, this all seems to stick around - even after closing the search&replace window and manually clearing the search results from the bottom dock.

Interestingly, shortly after I did that "clean up", I got another spike of a few MB and only about 50% of that was recovered within the next minute or so.

YYDan commented 2 weeks ago

Okay, solid repro in a project everyone has access to, so I have updated the steps above and added more definite numbers for each.

@gnysek Could you do my steps and let us know if you see drastically higher RAM usage numbers, please?

YYDan commented 2 weeks ago

If I close the project and return to the Start Page, then I very quickly drop in chunks until I reach about 245MB, but then any further drops are much smaller and slower. Settles eventually at about 210MB.

gnysek commented 1 week ago

After searching few times in this project: obraz

They're bigger for me if any of results (code, object) was opened at least once.