On Mon, 10 Jan 2005 12:53:50 +0200, Octavian Rasnita <[EMAIL PROTECTED]> wrote: > Hi, > > I have made a perl module object oriented which is something like this: >
> Then I access the parse() method in another program that feeds the module > with more Excel files (around 500 files). > > After more files parsed (around 300), the memory is full. > > Please tell me what can I do to free the memory after each file parsed by > the module. > > I run this program manually or by a cron job, but I would like to know > better how to free the memory because I might want to use it under mod_perl. > > Thank you very much for any tip. > > Teddy > Teddy, This is one of the tricky parts of objects and pass-by-reference applications: a refence never goes out of scope, so it's memory is never reclaimed. Think about what would happen, for example, if you created 500 hundred references to DBD::mysql handles, or similar, and never called $handle->disconnect() on any of them. What you need to do is write a method that, when called, will make sure that all that everything associated with the object it's passed is dereferenced. In the main program, you can call it explicitly when you're done with each object when you're done with it. When you call it, the code should look something like this: foreach (@files) { my $obj = yourmod->parse($_) ; # do something to $obj $obj->destroy() or warn "can't dereference" ; } HTH --jay -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>