看板 Perl 關於我們 聯絡資訊
※ 引述《C6H5CH3 (甲苯)》之銘言: : 我的程式必須開數百個thread : 原本沒有thread時一個loop會讓記憶體的使用率增加200k左右 : 但我開了thread之後 : 每一個loop會讓記憶體增加5~6MB : 後來看了下面文章 : http://www.oreilly.com.tw/column_sleepless.php?id=j005 : 覺得原因可能跟上面說的一樣 : 想請問perl有沒有可以手動釋放記憶體的方式 : 先謝過各位前輩...:) perl使用reference counting 沒有被reference到的變數會自動回收 和java用額外的thread不同 你的情況應該是使用許多global variable perl使用interpreter thread 每個thread都有自己一份global variable 避免浪費的方法是宣告為shared如下 use threads; use threads::shared; my $foo : shared; -- DO NOT disturb my programs! -- From Archimedes' last word, and may be my last word. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.244.211