Sarrus1 / sourcepawn-studio

VSCode extension for SourcePawn scripting
https://sarrus1.github.io/sourcepawn-studio/
MIT License
139 stars 21 forks source link

Possible memory leaks #367

Closed MAGNAT2645 closed 4 months ago

MAGNAT2645 commented 4 months ago

Basic informations

Further Information

Right after i open any folder, the extension starts indexing files. When this happens, it eats all of my RAM and then all of the Swap partition until whole system freezes. I can see that by looking at the indicators of xfce4-systemload-plugin. Memory leaks stopped when i switched back to v6.2.0.

To Reproduce

Idk just set includeDirectories to the .../sourcemod/scripting/include (with the full path) where all possible includes are located (and in the subfolders too). Then load any folder (or workspace) with a lot of #includes (but not that really much). It will print at the bottom Indexing: 0/1 (Folder Name) (or something like that) while eating all the memory in the system.

Code to reproduce the behaviour


Expected behaviour

Just. Dont. Eat. All of my RAM. I cant test v7.0.0 due to this.

Error messages

I cant really look at any logs and copy them because when all RAM is used, it just freezes and i have to wait when system will unfreeze releasing as mush memory as possible.

Sarrus1 commented 4 months ago

Ouch, odd. Does this reproduce in a "simple project" with just an empty sourcepawn file that includes sourcemod?

MAGNAT2645 commented 4 months ago

If you meant to create new folder and open it with just one sp file including #include <sourcemod> then it does nothing. Absolutely. Autocompletion does not work, IntelliSense does not show any information about what i'm typing. Tested with this:

#include <sourcemod>

Handle hStuff;

public void OnMapStart()
{

}

The only working thing here is when i'm holding Ctrl while hovering above <sourcemod> and Handle. Clicking on <sourcemod> brings me to my local sourcemod.inc (which is located in the folder with path specified in the includeDirectories setting) and Linter throws this error 3 times (different lines):

methodmap `Handle` does not exist

Handle brings me to the definition of Handle enum. This one

enum Handle // Tag disables introducing "Handle" as a symbol.
{
    INVALID_HANDLE = 0
};

Nothing about OnMapStart.

Sarrus1 commented 4 months ago

If you meant to create new folder and open it with just one sp file including #include then it does nothing. Only GoToDefinition and the linter are implemented for now. So if CTRL + click on Handle brings you to the definition then that's good, it works.

I think the extension does not like the files you have in your other workspace for some reason. Can you please send them to me in a zip, as well as the contents of sourcemod/scripting/include? That would help me to replicate the issue!

I have tried with other sp projects (surftimer) and GoToDefinition works fine, no memory spike.

MAGNAT2645 commented 4 months ago

Can i send you zip via Discord (if it will allow the file size)? And i can give you access to one of my GitHub repos so you can check by yourself. Code in my remote repos is a bit outdated comparing to my local repos but i think this will happen even with the code from remote repos.

Sarrus1 commented 4 months ago

Yes that works, my discord is @sarrus_

MAGNAT2645 commented 4 months ago

I have invited you to the one of my repos.

njopia commented 4 months ago

I´d like to add that i do have same issue since last update. Reproduce it: 1.- SM: Install Sourcemod 1.11 stable 2.- Overriding JSON 3.- Creating basic script file. 4.-Compilling...

Indexing and VSCode got frezze. I repeat 2 times more the same scenario. got same results

image

Sarrus1 commented 4 months ago

Managed to repro the issue, will try to fix in ~6h

njopia commented 4 months ago

After today´s update, i see a drecrease of needed resources. Also index problems are not present in my case. Thanks. image

Sarrus1 commented 4 months ago

Likely found the cause of the issue: Salsa invalidates data behind queries, but not keys... I am passing huge keys to salsa, which is terrible for performance.