in reply to Problem in RAM usage while threading the program

It seems like each thread is taking a copy of hash (and each hash is ~100 GB

Hi

Sounds about right, see threads::shared, and study Re^5: threading a perl script?;spoil=1;node_id=901037, Thread::Queue...

 

continually creating 40 new threads is not as fast as creating only 40 threads :)

 

in perl initThreads is written as  my @initThreads = 1..$num_of_threads; but

There is no need to maintain a list of threads, the threads module already does that

threads->list(threads::joinable)