Pocketmine-mp: Type error when main-hard-memory-limit is set to disabled

Created on 12 Jun 2017  Â·  1Comment  Â·  Source: pmmp/PocketMine-MP

Issue description




When main-hard-memory-limit is set to disabled, when it sets the max memory thru ini_set it expects a string instead the server returns -1 which is an integer, therefore causes this error.

Steps to reproduce the issue

  1. Edit pocketmine.yml and set main-hard-limit to 0.
  2. Start the server and watch the server crash repeatedly.

OS and versions

  • PocketMine-MP: Latest, branch master. Commit 433b8369f5a7ac9d334998c874a0c5cf63bbebd2
  • PHP: 7.0.3
  • Server OS: Linux Centos7
  • Game version: PE/Win10

Error/backtrace

Error: ini_set() expects parameter 2 to be string, integer given
File: /src/pocketmine/MemoryManager
Line: 95
Type: notice

Code:
[86]                        $defaultMemory = $m;
[87]                        break;
[88]                }
[89]            }
[90]        }
[91] 
[92]        $hardLimit = ((int) $this->server->getProperty("memory.main-hard-limit", $defaultMemory));
[93] 
[94]        if($hardLimit <= 0){
[95]            ini_set("memory_limit", -1);
[96]        }else{
[97]            ini_set("memory_limit", $hardLimit . "M");
[98]        }
[99] 
[100]       $this->globalMemoryLimit = ((int) $this->server->getProperty("memory.global-limit", 0)) * 1024 * 1024;
[101]       $this->checkRate = (int) $this->server->getProperty("memory.check-rate", 20);
[102]       $this->continuousTrigger = (bool) $this->server->getProperty("memory.continuous-trigger", true);
[103]       $this->continuousTriggerRate = (int) $this->server->getProperty("memory.continuous-trigger-rate", 30);
[104] 
[105]       $this->garbageCollectionPeriod = (int) $this->server->getProperty("memory.garbage-collection.period", 36000);

Backtrace:
#0 /src/pocketmine/MemoryManager(95): ini_set(string memory_limit, integer -1)
#1 /src/pocketmine/MemoryManager(62): pocketmine\MemoryManager->init(boolean)
#2 /src/pocketmine/Server(1457): pocketmine\MemoryManager->__construct(pocketmine\Server object)
#3 /src/pocketmine/PocketMine(501): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string /, string /plugins/)
Core Fixed

>All comments

This happen to me too bc my phone is 32-bit. Try set all memory
configuration to 4095 or below. It should fix it.

On Jun 12, 2017 12:33 PM, "Michael" notifications@github.com wrote:

Issue description

When main-hard-memory-limit is set to disabled, when setting the max
memory thru ini_set it expects a string instead the server returns -1 which
is an integer, therefore causes this error.
Steps to reproduce the issue

  1. Edit pocketmine.yml and set main-hard-limit to 0.
  2. Start the server and watch the server crash repeatedly.

OS and versions

Error/backtrace

Error: ini_set() expects parameter 2 to be string, integer given
File: /src/pocketmine/MemoryManager
Line: 95
Type: notice

Code:
[86] $defaultMemory = $m;
[87] break;
[88] }
[89] }
[90] }
[91]
[92] $hardLimit = ((int) $this->server->getProperty("memory.main-hard-limit", $defaultMemory));
[93]
[94] if($hardLimit <= 0){
[95] ini_set("memory_limit", -1);
[96] }else{
[97] ini_set("memory_limit", $hardLimit . "M");
[98] }
[99]
[100] $this->globalMemoryLimit = ((int) $this->server->getProperty("memory.global-limit", 0)) * 1024 * 1024;
[101] $this->checkRate = (int) $this->server->getProperty("memory.check-rate", 20);
[102] $this->continuousTrigger = (bool) $this->server->getProperty("memory.continuous-trigger", true);
[103] $this->continuousTriggerRate = (int) $this->server->getProperty("memory.continuous-trigger-rate", 30);
[104]
[105] $this->garbageCollectionPeriod = (int) $this->server->getProperty("memory.garbage-collection.period", 36000);

Backtrace:

0 /src/pocketmine/MemoryManager(95): ini_set(string memory_limit, integer -1)

1 /src/pocketmine/MemoryManager(62): pocketmine\MemoryManager->init(boolean)

2 /src/pocketmine/Server(1457): pocketmine\MemoryManager->__construct(pocketmine\Server object)

3 /src/pocketmine/PocketMine(501): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string /, string /plugins/)

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/pmmp/PocketMine-MP/issues/1074, or mute the thread
https://github.com/notifications/unsubscribe-auth/ARW33bvq4msMaQEgg9prvK4aTCa5e0Jnks5sDL-LgaJpZM4N2pW2
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RedstoneAlmeida picture RedstoneAlmeida  Â·  3Comments

dktapps picture dktapps  Â·  3Comments

Hugheth picture Hugheth  Â·  3Comments

XDqrkneZ picture XDqrkneZ  Â·  3Comments

sergeysova picture sergeysova  Â·  3Comments