in reply to Re: WWW::Mechanize memory leak???
in thread WWW::Mechanize memory leak???

It might be more useful to remove element base on its age. As the frequency you accessing web is not the same through out the day, and when you are busy surfing, you don't want the history get cleaned up quicker than the time you are mainly idle.

You may modify the structure of $self->{page_stack} a little bit, so that a time stamp is kept, and only those ones older than a certain age will get deleted.

However, as you are subclassing, it is probably a better idea to keep $self->{page_stack} as it is, and add a new array $self->{page_time_stamp}. The elements of those two arrays match 1-on-1.

The performance for deleting would be good, as the ones need to be deleted always stay together at the beginning of the array.