I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2012-07-12 07:56:33.517947-07 by mcv
threads::shared memory leak on updating shared variables
I am initializing a global shared variable as such:

my $CLIENT_DATA : shared;

Then, within a thread I do the following:

# returns a perl data structure, hash of hashes
my $tmp = initClientData( $dbh );
lock($CLIENT_DATA);
$CLIENT_DATA = shared_clone($tmp);

Each time I do this, the contents of $CLIENT_DATA gets updated properly, but the memory footprint of the process goes up. Is this expected, and is there any way to avoid this?

Thanks,
Matt
Direct Responses: 13746 | Write a response
Posted on 2012-07-12 09:20:38.985964-07 by jdhedden in response to 13745
Re: threads::shared memory leak on updating shared variables
Without seeing more of your code, it's hard to say what else you might do for this. One idea is to have InitClientData() generate the data such that it's already shared so you don't have to do shared_close(). If the thread is not exiting, then you can undef($tmp) to clear the memory it's holding on to. Use a bare 'return;' at the end of your thread subroutine to ensure it's not returning a copy of anything on exit. If your data structure is known and reusable, you could try:
lock($CLIENT_DATA); # InitClientData will initialize the existing data structure initClientData( $dbh, $CLIENT_DATA );
Direct Responses: Write a response