public static function FPAFormBuilder::getRequiredMemory in Fast Permissions Administration 8.2
Same name and namespace in other branches
- 3.0.x src/FPAFormBuilder.php \Drupal\fpa\FPAFormBuilder::getRequiredMemory()
Return value
int Approximate number of bytes of ram required to render the permissions form.
1 call to FPAFormBuilder::getRequiredMemory()
File
- src/
FPAFormBuilder.php, line 28 - Contains Drupal\fpa\FPAFormBuilder.
Class
- FPAFormBuilder
- Class FPAFormBuilder.
Namespace
Drupal\fpaCode
public static function getRequiredMemory($suffix = '') {
$permission = \Drupal::service('user.permissions');
$permissions_count = count($permission
->getPermissions());
$user_roles_count = count(user_roles());
$page_ram_required = 9 * 1024 * 1024;
// Takes ~26kb per row without any checkboxes.
$permission_row_overhead = 27261.028783658;
$permissions_ram_required = $permissions_count * $permission_row_overhead;
// Determined by checking peak ram on permissions page, over several different number of visible roles.
$bytes_per_checkbox = 18924.508820799;
$checkboxes_ram_required = $permissions_count * $user_roles_count * $bytes_per_checkbox;
$output = (int) ($page_ram_required + $permissions_ram_required + $checkboxes_ram_required);
if (!empty($suffix)) {
return $output . $suffix;
}
return $output;
}