DavideViolante / investing-com-api

Unofficial APIs for Investing.com website.
MIT License
78 stars 26 forks source link

Max memory and restart windows server #121

Open PhamHuyThien opened 5 months ago

PhamHuyThien commented 5 months ago

Hello I am currently having some major problems using it

After starting the system for about 1 hour - 2 hours, RAM usage suddenly increases to 90% and restarts the server Currently, I have used PM2 and rebooted every hour but the RAM is still at 90%.

My device configuration: Windows server 2016 RAM: 16GB CPU: 8 cores 400GB SSD

my source:

async investing(body = {
        type: 'klines/realtime',
        name: '', //https://github.com/DavideViolante/investing-com-api/blob/master/mapping.js
        period: 'P1D, P1W, P1M, P3M, P6M, P1Y, P5Y, MAX',
        interval: 'PT1M, PT5M, PT15M, PT30M, PT1H, PT5H, P1D, P1W, P1M',
        pointcount: '60, 70, 120',
        pptrLaunchOptions: undefined,
    }) {
        let response = await investing(body.name, body.period, body.interval, Number(body.pointcount), body.pptrLaunchOptions);
        return ....
    },

Looking forward to receiving comments.

PhamHuyThien commented 4 months ago

https://github.com/PhamHuyThien/investing-com-api-v2

I forked the project and upgraded to version V2.0 Fix error: RAM memory overflow

DavideViolante commented 4 months ago

Hello, can you elaborate more how did you fix your problem, for future users? Is there a memory leak in my repo?

PhamHuyThien commented 4 months ago

Hello, can you elaborate more how did you fix your problem, for future users? Is there a memory leak in my repo?

Hello author,

Not receiving a response from you, I think I have to solve this problem myself. According to my investigation, closing the browser every time the API is called causes a big problem, sometimes 'puppeteer' cannot close itself (when making multiple calls in a row) the chromium windows stay active, stopping the project also does not solve the problem The way I solved it is instead of starting puppeteer continuously I just open a browser and open multiple tabs and end it each time I'm done working. I tested opening/closing 200 tabs continuously for 3 hours, the number of suspended tabs was very small (+-5 tabs).

Use my version 2 or upgrade your project, better experience.

End :)