'parfor' Memory Usage Greater Than Expected

7 ビュー (過去 30 日間)
Jay
Jay 2014 年 9 月 5 日
コメント済み: Jay 2014 年 9 月 12 日
Just before the execution of a particular loop in my code the memory usage will be ~6GB.
If I use 'for' then the memory usage will increase by ~600MB during execution of a single loop and drop back down.
If I use 'parfor' with just 2 workers the memory usage will exceed my 32GB of RAM and 32GB of swap.
Here is the loop:
parfor n=1:length( loop_Unique_Handle_Object_Array )
result{n} = someFunction( shared_Data,...
loop_Unique_Handle_Object_Array(n) );
end
'shared_Data' is 100MB
Each instance of loop_Unique_Handle_Object_Array is 200MB
I dont understand why the amount of RAM required by 'parfor' is greater than the amount required by 'for' * numWorkers + Overhead. Is this a result of using handle objects?

採用された回答

Matt J
Matt J 2014 年 9 月 5 日
編集済み: Matt J 2014 年 9 月 5 日
Is this a result of using handle objects?
Possibly. All data that a handle object points to will be cloned and transmitted to the workers. It's not clear how you would have measured the memory footprint of everything your handle object points to and concluded that it is 200MB. MATLAB doesn't have any direct tools that would let you measure this footprint (whos() will not be reliable, in particular).
An easy test would be to just do a simplified parfor which only broadcasts the handle objects
parfor n=1:length( loop_Unique_Handle_Object_Array )
result{n} = loop_Unique_Handle_Object_Array(n);
end
  8 件のコメント
Matt J
Matt J 2014 年 9 月 9 日
That sounds like a good idea. You could also try trimming the memory footprint of the anonymous functions using this FEX file,
and see if that's of any help.
Jay
Jay 2014 年 9 月 12 日
Excellent, that looks real handy. I just ran into a different problem involving parfor and function handles that I think this may fix.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by