bestlong / node-red-contrib-mssql-plus

A Node-RED node to read and write to Microsoft MS SQL Databases
MIT License
31 stars 18 forks source link

Memory leak is still happen in both of newest version and prior version. #64

Open BADEnder opened 1 year ago

BADEnder commented 1 year ago

Memory Leak Case

There is Memory leak problem in both of your newest version 0.7.3 and prior version 0.3.3.

The testing flow was that you mentioned in the previous issue, but I changed the input more quick, For example, 7200pcs / 5 seconds, and change the delay node to 10msg/s (My work space need the input more large and more fast)

In this case, after running node-red around 1.5hours, the memory usage in node-red from 4% to 40%, and then node-red crashed.
Crashed again no matter how much times node-red restart.


Problem Solved after I modified your code, and very pleasure to improve your code.

However, I changed lots of your version 0.3.3 code, and actually there is no memory leak again, the problem is solving. I am pleasure to help you to improve your code or maybe you can merge my code, but first I have couples of questions for you:

  1. First of all, why did you use the module mustache and others for the MS-SQL configuration input? After I saw the page of module mustache page, I found that was major use for HTML template, am I correct? Therefore, I tried to delete it all in the red frame of picture (as shown below), I found the output that was no difference to your origin code. Here is your version 0.3.3 code: image Could you simply explain me what you were doing here?

  2. Second, I noticed that you create new promise object for every node-mssql input, I am not sure whether the node-red use the cahch for every node. If yes, I guess that was very big problem. Why did you create a new promise object to include node-mssql promise object?

After I deleted these two point, and modified the code, the memory leak was never happen again even thought I set the input 9700 msg / 2 seconds, and total input 70 million messages.

Please help me, thanks.

adikos commented 1 year ago

Hi @BADEnder, I'm facing the same memory leakage with 0.7.3 version. Can you upload your corrected version to give it a try? Thanks.

uoral commented 1 year ago

Hello Mr. @Steve-Mcl ,

I'm facing that memory leakage problem too. Please update that version. Thank you so much.

BADEnder commented 1 year ago

@adikos The version I modified is version 0.3.3 as the picture above, not version 0.7.3

uoral commented 1 year ago

Hi @BADEnder ,

How can we modify that code?. Can you please explain that. With a program? I deleted the parts in the picture from the mssql.js file, but it didn't work. Please help me. Thank you.

uoral commented 1 year ago

Hello Mr @bestlong ,

Because of this problem(constant loss of ram) my program is not working properly and after a while the program gets blocked. Please a solution here. Thank you so much.

Kind regards.

bestlong commented 1 year ago

Hi @BADEnder @PyregTechnologie

Now node can disable parse mustache.

uoral commented 1 year ago

Hi Mr. @bestlong,

First of all, thank you very much for your quick response. Do we need to reinstall Mssql-plus Node? How can I implement this change in the code?

Kind Regards

BADEnder commented 1 year ago

@PyregTechnologie

If you use the version 0.3.3, you can just replace the mssql.js in "src" directory with the link below:

https://github.com/BADEnder/node-red-contrib-mssql-plus-m/blob/master/mssql.js

Not only delete the mustache and others, but also add some code referred to the module named "node-mssql"

bestlong commented 1 year ago

Hi @PyregTechnologie

First of all, thank you very much for your quick response. Do we need to reinstall Mssql-plus Node? How can I implement this change in the code?

Kind Regards

go to Manage palette update node and restart nodered.

then edit node property uncheck parse mustache

uoral commented 1 year ago

Hi @BADEnder @bestlong ,

Thank you very much for your answers and solutions.

Kind Regards

bestlong commented 1 year ago

If you use the version 0.3.3, you can just replace the mssql.js in "src" directory with the link below:

https://github.com/BADEnder/node-red-contrib-mssql-plus-m/blob/master/mssql.js

Not only delete the mustache and others, but also add some code referred to the module named "node-mssql"

Hi @BADEnder

We can't see node-red-contrib-mssql-plus-m. Private repository ?

BADEnder commented 1 year ago

Sorry, that's my fault, and it's public now. If you have any concern about the code, please let me know, thanks.

BADEnder commented 1 year ago

Hi @bestlong, what do you think after reviewed my modified code?

By the way, I test your newest version 0.10.x this Monday, and still got the memory leak.

In my opinion, maybe that's about the code creating a new promise object in node-red instead of using the promise object that's already built in the module "node-mssql". Therefore, I guess that the memory will keep going up if you don't delete those object to release the memory.