threads-shared - Re: Thread memory not being released.

Posted on Thu Nov 30 00:43:29 2006 by stratimus in response to 3661 (See the whole thread of 5)
Re: Thread memory not being released.
Sorry to not elaborate more. I should probably also mention that this is on a Win32 system for the time being, as I know it handles memory slightly differently. First off, I have object $Otherbody of the Otherbody class. Each module exports that variable so it can be accessed anywhere, and it's also shared across threads. Such methods on it are:
$Otherbody->uptime $Otherbody->master_password $Otherbody->in_motion (Which returns true as long as the server should be running) $Otherbody->shutdown (Which sets in_motion to false and cleans up some things) Etc.
Basically, the main script calls module Ansible.
my $AnsibleThread = threads->create( sub { Ansible::Initiate; } );
Part of Ansible::Initiate:
while($Otherbody->in_motion) { my $sock = $socket->accept(); if($sock) { $identifier++; $Otherbody->ansible_clients(2); #Raises the count on admins connected $thread[$identifier] = threads->create( sub { my $master = new Master($sock); $master->begin; pr +int "They left"; STDOUT->flush; close($sock); } ); } usleep(1000); }
And then in the Master module, just like the Ansible module, all variables are private with the exception of $Otherbody which as I have said as shared in everything. Once the client is gone, begin ends and it's cleaned up. Am I doing this a bad way or is there just some circular reference causing this that can be fixed? I feel it might be $Otherbody causing it. Hope that is good enough, thanks.
Direct Responses: 3664 | Write a response