フィルターのクリア

How to avoid memory leaks when function inside parfor generates warning?

9 ビュー (過去 30 日間)
Jonas
Jonas 2017 年 3 月 30 日
コメント済み: xl z 2023 年 11 月 13 日
Hello!
I use matlab R2015b for Win Server 2012 OS with local parpool. I have memory leaks on local workers when function inside parfor-loop generate warning. Also memory is not released after parfor-loop ends. Example:
x = rand(78, 1);
for j = 1:100
parfor i = 1:1000
[~, z] = kpsstest(x);
end
end
[~, z] = kpsstest(x) generates warning:
Warning: Test statistic #1 below tabulated critical values:
maximum p-value = 0.100 reported.
> In kpsstest>getStat (line 632)
In kpsstest (line 291)
Memory leaks on workers even when i use constructions:
warning('off', 'econ:kpsstest:StatTooSmall');
pctRunOnAll warning('off', 'econ:kpsstest:StatTooSmall')
Memory on start workers:
Memory on after executing code:
How to avoid memory leaks when function inside parfor generates warning?
Thank you.

採用された回答

Edric Ellis
Edric Ellis 2017 年 3 月 31 日
This problem is the subject of this bug report. If you are able to upgrade to R2017a, that's the simplest workaround.
  4 件のコメント
Jonas
Jonas 2018 年 10 月 12 日
Hello Isabel.
As I remember, in my case the solution was to divide the calculations into batches and after calculating one data batch, the parpool stopped and then restarted again (see pseudocode below).
for i = 1:numel(batches)
parpool('local', 'SpmdEnabled', false);
curData = batches{i};
parfor j = 1:numel(curData)
% DO SEMETHING THAT LEADS TO MEMORY LEAKAGE
end
delete(gcp('nocreate'));
end
It was a bad idea in point of performance, but it was quite stable. I hope it helps.
xl z
xl z 2023 年 11 月 13 日
MATLAB 2023a/2023b also has such bug

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by