We have a simple task running with django-celery on Heroku. Something like:
@task
Simple_task():
for line in csv.reader(origin):
process_line(line)
process_line(line):
fields = parse_line(line)
reg = Model1() # Django model
reg.field1 = fields[0]
reg.field2 = fields[1]
reg.field3 = fields[2]
reg.save()
Where origin is a csv file. When the file is big (more than 50.000 lines), the task takes up all memory, giving R14 errors until being cancelled by the system (at 150% of available memory of 512 MB). The memory is never released and we have to restart the task manually.
Running in a Linux machine or with foremen on the development machine, it completes with no problems (all 170.000 lines). It seems to be leaking memory ONLY on Heroku. By the way, we run with DEBUG=False.
Is something broken with Heroku implementation of celery tasks? Anything we can be missing? This has become a show-stopper on deploying on Heroku.
Any help would be highly appreciated.