Author Topic: Bad report : Increase your php memory limit, which is must too low to run VM  (Read 58 times)

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 1984
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
If you set php memory limit too 2048M, you get message
 
Quote
Increase your php memory limit, which is must too low to run VM ...

in config.php replace :
Code: [Select]
static function getMemoryLimitBytes(){
static $mLimit;
if($mLimit===null){
$mL = ini_get('memory_limit');
$mLimit = 0;
if(!empty($mL)){
$u = strtoupper(substr($mL,-1));
$mLimit = (int)substr($mL,0,-1);
if($mLimit>0){
if($u == 'M' or $u == 'MB'){
$mLimit *= 1048576;
} else if($u == 'G' or $u == 'GB'){
$mLimit *= 1073741824;
} else if($u == 'K' or $u == 'KB'){
$mLimit *= 1024;
}
$mLimit = (int) $mLimit - 5242880; // 5 MB reserve
if($mLimit<=0){
$mLimit = 1;
$m = 'Increase your php memory limit, which is must too low to run VM, your current memory limit is set as '.$mL.' = '.$mLimit.'B';
vmError($m,$m);
}
}
}

if($mLimit<=0) $mLimit = 2147483648;
vmdebug('My Memory Limit in Bytes '.$mLimit);
}

return $mLimit;
}

with :


Code: [Select]
static function getMemoryLimitBytes(){
static $mLimit;
if($mLimit===null){
$mL = ini_get('memory_limit');
$mLimit = 0;
if(!empty($mL)){
$u = strtoupper(substr($mL,-1));
$mLimit = (int)substr($mL,0,-1);
if($mLimit>0){
if($u == 'M' or $u == 'MB'){
$mLimit *= 1048576;
} else if($u == 'G' or $u == 'GB'){
$mLimit *= 1073741824;
} else if($u == 'K' or $u == 'KB'){
$mLimit *= 1024;
}
if($mLimit<5242880){
$mLimit = 1;

$m .= 'Increase your php memory limit, which is must too low to run VM, your current memory limit is set as '.$mL.' = '.$mLimit.'B';
vmError($m,$m);
}
}
}

if($mLimit<=0) $mLimit = 2147483648;
vmdebug('My Memory Limit in Bytes '.$mLimit);
}

return $mLimit;
}

(int) $mLimit - 5242880 do not return the right calculation and give a negative value