1

I pass the options as

{
...
chunk: () => this.chunk(results,parser),
complete: () => this.complete(results,parser)
}

And this doesn't leak memory when worker is false but leaks memory when worker is true. The leak is because the closures are somehow retained. Looking at the papaparse code it seems that the callback functions are copied to the worker object as worker.userXYZ functions. However, at the end the worker is terminated and deleted. So, ideally the closures should have been freed up too.

Is there any extra step required when using the worker option so the memory is freed up properly?

Siva
  • 1,096
  • 7
  • 20

1 Answers1

0

This seems to be related to Worker objects are not freed

I had a large object held up via the chunk function which refers to this. So, by setting the reference to null in complete freed up the memory.

Siva
  • 1,096
  • 7
  • 20
  • Could you elaborate on exactly how you set the reference to null? Nothing I've tried seems to work. – tfrancois Aug 17 '22 at 21:06
  • The chunk and complete handlers are referring to an object that is getting stuck because of the above mentioned worker objects problem. So, in the complete handler, I just set all member variables of the object to null. Those are the big ones that were piling up. There is still a small leak but it is very negligible. – Siva Aug 19 '22 at 00:15