anyevent-gearman-perl icon indicating copy to clipboard operation
anyevent-gearman-perl copied to clipboard

Fix memory leak and "unique" bug

Open athomason opened this issue 13 years ago • 6 comments

These commits respectively fix a memory leak (see https://github.com/typester/anyevent-gearman-perl/issues/1) and a bug in "unique"-specifying tasks.

athomason avatar Jun 26 '11 02:06 athomason

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.

typester avatar Jun 28 '11 02:06 typester

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.

athomason avatar Jul 01 '11 21:07 athomason

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!

martynsmith avatar Feb 01 '13 02:02 martynsmith

yup I can also confirm that it reduced a notable amount of memory usage

bluet avatar Feb 04 '13 10:02 bluet

Hi, I'll cut a release later today.

Thanks for the feedback.

melo avatar Feb 04 '13 11:02 melo

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.

melo avatar Feb 05 '13 11:02 melo