Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^4: Multithreading leading to Out of Memory error

by joemaniaci (Sexton)
on Jun 07, 2013 at 21:30 UTC ( [id://1037761]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Multithreading leading to Out of Memory error
in thread Multithreading leading to Out of Memory error

Well it's nice to see I wasn't going completely down the wrong path. I already removed Switch, and ParseExcel is actually the last thing done when all the threads have already been destroyed. I usually only come across 2-3 .xls files so that part is single threaded.

When it comes to DBI and DBI::ODBC I tried...

require DBI; require DBI::ODBC;

inside the methods that need it, instead of...

use DBI; use DBI::ODBC;

...at the very top but the behavior was very erratic.

Ironically enough I discovered this bug while getting ready to work on feeding the queue as soon as I found files with the correct extensions instead of, but I wanted to resolve this before attempting that.

I also thought about creating a single subroutine to handle each file type, but the issue is that one file type is always 1kb and so it's thread would be done in seconds and then not doing anything afterwards. While other files are gargantuan. The goal was that small/medium(which are the majority) files could be handled while the bigger files were being processed over time

This is how I grab all the files I need and it is only done once at the very beginning, before threads are created

find sub { $File = $File::Find::name, -d && '/'; $if($File =~ /\.extA$/ || $File =~ /\.extB$/ .....) { $File =~ s/some formatting stuff/; push(@FoundFiles, $File); } },$Directory;

Outside of that is pretty much all the file checks, making sure this line has the right number of items, bounds checks, so on and so forth. Nothing complicated, mostly simple regex stuff.

Replies are listed 'Best First'.
Re^5: Multithreading leading to Out of Memory error
by BrowserUk (Patriarch) on Jun 08, 2013 at 06:25 UTC
    When it comes to DBI and DBI::ODBC I tried... require inside the methods that need it, instead of... use ...at the very top but the behavior was very erratic.

    That would probably only work if you moved all the DBI handling into a single thread.

    Try to isolate each potentially troubling module and re-run checking for memory growth. There's not really much more I can add.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1037761]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-28 05:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found