in reply to Shared array memory leak in Perl5.8

I haven't checked the links provided here yet for lack of time. I have run into this in the past. The error I was having was with pop and shift not releasing the memory on shared arrays.

For a quick fix I changed the dequeue method in Thread::Queue to do a: delete $q->[-1] (which returns the value deleted) instead of a shift. I also changed the enqueue to unshift instead of push to return it the correct behavior of a queue. This seems to work.

Not sure if this will help, or what the internal differences between a delete and shift would be to a shared array. Good Luck.


Edited: Ah there certainly is a patch, I could of used that few months ago. :(

Replies are listed 'Best First'.
Re: Re: Shared array memory leak in Perl5.8
by sureshr (Beadle) on Jun 03, 2003 at 08:23 UTC
    Pete & Joost,

    The patch did'nt really help. I have updated the bug in the bug link>, bug id 15893, with a sample code that would reproduce the problem. I tried even using delete/unshift technique, which did'nt help either :(
    Currently, I am using a fixed size circular-Q, which would recycle a __MAX__ size array by overwriting the data that is read. Sometimes we would loose old-data due to overwriting, in which case I should choose a better Q size. Sounds not so good, but better than a memory leak :). I shall post more details if I find any update on this.

    Thank you,
    Suresh R