I have some 7 nestings for/foreach php script which crashed my computer many times, and eaten each time 200-500 Mb memory, more than 3GB in total.
I can not recover the memory.
Я использую opcache_reset();
в коде
также пытался в командной строке:
apt clean
apt autoremove --purge
apt-get autoremove
apt-get autoclean
apt-get clean
Где проблема с php?
opcache_reset();
$wayA = [
'way1' => [
'pr_w1' => [1, 6, 25, 50 ],
'revenue_w1' => 0,
'profit_w1' => 0,
'opex_w1' => [],
't_r_w1' => 0,
],
'way2' => [
'price_w2'=> [ 5, 10, 25, 50, 90 ],
'revenue_w2'=>0,
'profit_w2'=>0,
'opex_w2'=>0,
't_r_w2'=>0,
],
];
for ( $w=1; $w<2; $w++ ) {
for ( $e=1; $e<=21; $e+4 ) {
$ansA[$e][$w]=[];
$tw = $tz + $e * 100;
$tz = $tw;
for ( $t_rr=1; $t_rr<2; $t_rr++ ) {
$t_r=5 + $t_rr*20; //tourists
for ( $pr_rr=1; $pr_rr<2; $pr_rr++ ) {
$pr_r= 5+ $pr_rr*15; //price
for ( $opex_rr=1; $opex_rr<2; $opex_rr++ ) {
$opex_r= 9 + $opex_rr*20; //opex
for( $N=1; $N<=2; $N++ ) {
$pr_wX_key ='pr_w'.$N; //'price_w1' = 'pr_w1'
$wayX_key='way'.$N;
foreach ( $wayA[$wayX_key][$pr_wX_key] as $pr ) {
$pr_wX = $pr / $pr_r;
$opex_wX = $pr_wX * $opex_r/100;
$t_NX = $tz * $t_r/100;
$rev_wX = $t_NX * $pr_wX;//revenue = tourist numer * price
$prof_bt_wX = $pr_wX - $opex_wX; //profit
$pr_wX_kX = 'pr_w'.$N;
$opex_wX_kX = 'opex_w'.$N;
$t_r_wX_kX = 't_r_w'.$N;
$rev_wX_kX = 'rev_w'.$N;
$prof_bt_wX_kX = 'prof_bt_w'.$N;
$ansA[$w][$e][$t_NX_k]=[];
$pr_wX_k= sprintf('%g',$pr_wX);
$opex_wX_k= sprintf('%g',$opex_wX);
$ansA[$w][$e][$t_NX_k][$pr_wX_k]=[];
$ansA[$w][$e][$t_NX_k][$pr_wX_k][$opex_wX_k]=[];
$ansA[$w][$e][$t_NX_k][$pr_wX_k][$opex_wX_k][$pr_wX_kX] = $pr_wX; //'pr_w1'
$ansA[$w][$e][$t_NX_k][$pr_wX_k][$opex_wX_k][$opex_wX_kX] = $opex_wX; //'opex_w1'
$ansA[$w][$e][$t_NX_k][$pr_wX_k][$opex_wX_k][$t_r_wX_kX] = $t_NX; // 't_r_w1'
$ansA[$w][$e][$t_NX_k][$pr_wX_k][$opex_wX_k][$rev_wX_kX] = $rev_wX; // 'rev_w1'
$ansA[$w][$e][$t_NX_k][$pr_wX_k][$opex_wX_k][$prof_bt_wX_kX] = $prof_bt_wX; //'prof_bt_w1'
} // for ( way1['price_w1' as
} // for( $N=0; $N<4; $N++ )
} // for ( t_r_w1=5; t_r_w1<100; t_r_w
} // for ( opex_w1_r=9; opex_w
} // for ( price_w1=1; price_w
} // for ( $w=1; $w<250; $w++
} // for ( $e=1; $e<10
Я вырезал / вставил несколько 3ГБ файлов / home на другой диск, но каждый раз, когда я запускаю скрипт, я заканчиваю sh с 0 байтами свободной памяти в / home. Почему?