Author Topic: Bad memory limit report break product display.  (Read 1255 times)

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3248
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Bad memory limit report break product display.
« on: November 17, 2016, 01:15:48 am »
Tested on Vm 3.0.18, Joomla 3.6.4, php 5.6; 1go limit
Code: [Select]
if ($this->memory_limit<$mem = round(memory_get_usage(FALSE)/(1024*1024),2)) {
vmdebug ('Memory limit reached in model product getProduct('.$virtuemart_product_id.'), consumed: '.$mem.'M');
vmError ('Memory limit reached in model product getProduct() ' . $virtuemart_product_id);
return false;
}
use bad memory usage and don't load any products !
Only on using PHP 7.0, it work but report :
$this->memory_limit : -3 (negative value)
rounded memory_get_usage : 5.5
So it work only because php 7 report negative value
the string value is for memory limit is "1G"  (one giga) as default perhaps is your convertion bad when server limit use G and not M ?

This is the virtuemart debug :

vmdebug Start used Ram 4.5M
vmdebug getVendorId normal shopper
vmdebug vmTime: sortSearchQuery products: 0.0241389274597168
vmdebug Memory limit reached in model product getProduct(7225), consumed: 4.9M
vmdebug Memory limit reached in model product getProduct(6667), consumed: 4.9M
vmdebug Memory limit reached in model product getProduct(6540), consumed: 4.9M
vmdebug Memory limit reached in model product getProduct(7080), consumed: 4.9M
vmdebug Memory limit reached in model product getProduct(7079), consumed: 4.91M
vmdebug Memory limit reached in model product getProduct(6998), consumed: 4.91M
vmdebug Memory limit reached in model product getProduct(6999), consumed: 4.91M
vmdebug Memory limit reached in model product getProduct(7156), consumed: 4.91M
vmdebug Memory limit reached in model product getProduct(7120), consumed: 4.91M
vmdebug Memory limit reached in model product getProduct(6957), consumed: 4.91M
vmdebug Memory limit reached in model product getProduct(6994), consumed: 4.91M
vmdebug Memory limit reached in model product getProduct(6995), consumed: 4.91M
vmdebug Memory limit reached in model product getProduct(7052), consumed: 4.91M
vmdebug Memory limit reached in model product getProduct(7049), consumed: 4.91M
vmdebug Memory limit reached in model product getProduct(7113), consumed: 4.91M
vmdebug Memory limit reached in model product getProduct(7115), consumed: 4.91M
vmdebug Memory limit reached in model product getProduct(7114), consumed: 4.91M
vmdebug Memory limit reached in model product getProduct(6595), consumed: 4.92M
vmdebug Memory limit reached in model product getProduct(1377), consumed: 4.92M
vmdebug Memory limit reached in model product getProduct(7123), consumed: 4.92M
vmdebug Memory limit reached in model product getProduct(7283), consumed: 4.92M
vmdebug Memory limit reached in model product getProduct(7282), consumed: 4.92M
vmdebug Memory limit reached in model product getProduct(7154), consumed: 4.92M
vmdebug Memory limit reached in model product getProduct(7088), consumed: 4.92M
vmdebug Memory limit reached in model product getProduct(7087), consumed: 4.92M
vmdebug Memory limit reached in model product getProduct(7098), consumed: 4.92M
vmdebug Memory limit reached in model product getProduct(7101), consumed: 4.92M
vmdebug Memory limit reached in model product getProduct(7032), consumed: 4.92M
vmdebug Memory limit reached in model product getProduct(7100), consumed: 4.92M

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9608
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Bad memory limit report break product display.
« Reply #1 on: November 17, 2016, 13:44:53 pm »
Thank you for the report

I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

advergroup

  • Beginner
  • *
  • Posts: 32
Re: Bad memory limit report break product display.
« Reply #2 on: April 17, 2018, 19:38:09 pm »
I am having the same issue with VirtueMart 3.2.12 and Joomla 3.8.6

Any ideas how I can resolve??

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3248
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: Bad memory limit report break product display.
« Reply #3 on: April 17, 2018, 21:30:04 pm »
I am having the same issue with VirtueMart 3.2.12 and Joomla 3.8.6

Any ideas how I can resolve??
If you can use 1024M or 2048M ....

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9608
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Bad memory limit report break product display.
« Reply #4 on: April 20, 2018, 00:07:29 am »
Thank you for the report

I am quite sure I worked on that. Maybe you find the missing piece, Patrick.

Code: [Select]
if ($this->memory_limit<$mem = memory_get_usage(FALSE)) {

$this->memory_limit is set with $this->memory_limit = VmConfig::getMemoryLimitBytes(); and here is the code

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;
}

$mTest = $mLimit - 5242880; // 5 MB reserve

if($mTest<=0){
$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 = 2142240768;
vmdebug('My Memory Limit in Bytes '.$mLimit);
}

return $mLimit;
}
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

franzytcha

  • Beginner
  • *
  • Posts: 1
Re: Bad memory limit report break product display.
« Reply #5 on: May 02, 2018, 21:44:24 pm »
Any solution?

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9608
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Bad memory limit report break product display.
« Reply #6 on: May 02, 2018, 22:02:06 pm »
Reading my code, I just noticed that

Code: [Select]
$mLimit = (int)substr($mL,0,-1);
if($mLimit>0){
if($u == 'M' or $u == 'MB'){
$mLimit *= 1048576;
} else if($u == 'G' or $u == 'GB'){
So $u can never be GB. Because $u is always just the last char. Maybe there is the problem.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

jcant

  • Beginner
  • *
  • Posts: 1
  • A beginner
Re: Bad memory limit report break product display.
« Reply #7 on: August 07, 2018, 09:41:05 am »
in my case
memory_limit = 83886080 (in php.ini)

static function getMemoryLimitBytes() (from administrator\components\com_virtuemart\helpers\config.php)
returned 8388608 and I had many "Memory Limit" errors.

I did some changes:
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));

if ((ord($u)>=48)&&(ord($u)<=57)) $mLimit = (int)($mL);
else $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;
}

$mTest = $mLimit - 5242880; // 5 MB reserve

if($mTest<=0){
$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 = 2142240768;
vmdebug('My Memory Limit in Bytes '.$mLimit);
}

return $mLimit;
}

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3248
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: Bad memory limit report break product display.
« Reply #8 on: August 07, 2018, 10:36:14 am »
using 83886080 without any format is set as octets(bytes) i think, so only 80MO.
Use 2048M, 1024M or 1048576K