Open AJAYK-01 opened 3 years ago
Upon further inspection, the memory spike seems to only occur when the scrape() is called in line 22, bot.py
There is no spike when that line is commented out 🤔
Then memory spike is less when using html.parser instead of html5lib, but ktu site tends to have broken html tags at times, so it is risky to use html.parser
The issue is caused by the soup object which is not getting destroyed after each scrape.
Tried making soup = None followed by gc.collect() but doesn't seem to have any effect.
Describe the bug:
When the APScheduler runs the function scheduledjob (line 70, bot.py), the RAM useage spikes up over time, reaching an unreasonable high value (upto 1GB useage in less than a day's use! ), thereby making the bot unhosteable on any of the free plans of common hosting providers.
To Reproduce:
Steps to reproduce the behavior:
Expected behavior:
The memory useage spikes up with each run of schedule job slowly, and the spike is much more profound when a new notification comes in the KTU website and the bot starts to send users the notification.
Screenshots:
Gradual increase of memory useage:
Eventually crossing free tier quota on heroku:
Additional context:
Currently the bot is being restarted by a systemd timer every hour in a custom VPS, but this hacky solution can't be used when hosting on hosting providers like heroku.