I have a django site that is running some heavy computational stuff that is scheduled with APScheduler hosted on Heroku. Everything is working as intended however Heroku is throwing error "Error R14 (Memory quota exceeded)" I have found other posts similar to this, link, issue but they are outdated and I haven't been able to get them to work. My code is listed below. I want this to run Mon-Fri between the hours of 800 and 1600. I am using heroku's PostgreSQL database. Eventually memory usage will get so high it will crash and restart.
sched = BlockingScheduler(
executors={
'threadpool': ThreadPoolExecutor(max_workers=1),
'processpool': ProcessPoolExecutor(max_workers=1)
}
)
@sched.scheduled_job('cron', minute='*/30', day_of_week='mon-fri', hour='8-18', max_instances=1, id="server",
executor='threadpool')
def _server():
print('Start server')
server = Server()
server.get_stocks()
del server
gc.collect()
sched.start()
I know this is leaking memory because this clock.py memory usage before the server starts.
This is after the server has done its' work and rests.
If anyone can point me in the right direction I am open to trying anything. Thank you in advanced.