anyevent-gearman-perl
anyevent-gearman-perl copied to clipboard
Fix memory leak and "unique" bug
These commits respectively fix a memory leak (see https://github.com/typester/anyevent-gearman-perl/issues/1) and a bug in "unique"-specifying tasks.
Hi, thanks for the commit! But I applied your first commit but not for second.
I didn't understand the situation that there is same job_handle for multiple jobs. For example, if there's two tasks A (long task) and B (short task), and have same job handle, your implementation only handle for task B. This is probably wrong.
Hi typester, thanks for reviewing this. The problem is the line "$self->_job_handles->{ $job_handle } = $task;". If another caller has already submitted a task with the same $job_handle to the client object, the existing task in the hash is lost. This is a problem when a "unique" tag is given, because the $job_handle is the same, and only the last caller to submit a job will have its callbacks fired. The test in b357f15 demonstrates the problem; I have added it to the pull request.
I just tried applying this patch (well just the Client/Connection.pm part honestly) and it seems to have fixed quite a lot of the memory leak issues I was having. Time will tell if I'm still leaking memory elsewhere :-)
It'd be really nice if this could be merged and released to CPAN!
yup I can also confirm that it reduced a notable amount of memory usage
Hi, I'll cut a release later today.
Thanks for the feedback.
Release 0.10 is on PAUSE now, should be on CPAN soon. It includes the leak fix that @typester already had on master, nothing else.