PocketMine-MP
5.28.3 git-d5a1007c80fcee27feb2251cf5dcf1ad5a59a85c
Loading...
Searching...
No Matches
LowMemoryEvent.php
1
<?php
2
3
/*
4
*
5
* ____ _ _ __ __ _ __ __ ____
6
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10
*
11
* This program is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU Lesser General Public License as published by
13
* the Free Software Foundation, either version 3 of the License, or
14
* (at your option) any later version.
15
*
16
* @author PocketMine Team
17
* @link http://www.pocketmine.net/
18
*
19
*
20
*/
21
22
declare(strict_types=1);
23
24
namespace
pocketmine\event\server;
25
26
use
pocketmine\event\Event
;
27
use
pocketmine\utils\Process
;
28
33
class
LowMemoryEvent
extends
Event
{
34
public
function
__construct(
35
private
int
$memory,
36
private
int
$memoryLimit,
37
private
bool
$isGlobal =
false
,
38
private
int
$triggerCount = 0
39
){}
40
44
public
function
getMemory
() : int{
45
return $this->memory;
46
}
47
51
public
function
getMemoryLimit
() : int{
52
return $this->memoryLimit;
53
}
54
58
public
function
getTriggerCount
() : int{
59
return $this->triggerCount;
60
}
61
62
public
function
isGlobal() : bool{
63
return $this->isGlobal;
64
}
65
69
public
function
getMemoryFreed
() : int{
70
$usage =
Process
::getAdvancedMemoryUsage();
71
return
$this->getMemory() - ($this->isGlobal() ? $usage[1] : $usage[0]);
72
}
73
}
pocketmine\event\Event
Definition
Event.php:33
pocketmine\event\server\LowMemoryEvent
Definition
LowMemoryEvent.php:33
pocketmine\event\server\LowMemoryEvent\getMemory
getMemory()
Definition
LowMemoryEvent.php:44
pocketmine\event\server\LowMemoryEvent\getMemoryLimit
getMemoryLimit()
Definition
LowMemoryEvent.php:51
pocketmine\event\server\LowMemoryEvent\getMemoryFreed
getMemoryFreed()
Definition
LowMemoryEvent.php:69
pocketmine\event\server\LowMemoryEvent\getTriggerCount
getTriggerCount()
Definition
LowMemoryEvent.php:58
pocketmine\utils\Process
Definition
Process.php:45
src
event
server
LowMemoryEvent.php
Generated by
1.12.0