Skip to content

Fatal memory issue when using permission names #2829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
waleed1892 opened this issue Apr 9, 2025 · 6 comments
Open

Fatal memory issue when using permission names #2829

waleed1892 opened this issue Apr 9, 2025 · 6 comments

Comments

@waleed1892
Copy link

Description

Laravel version= 11
Package version= 6
php version = 8.2

I'm facing fatal memory issue when I pass permission in string to any method and all my controllers return 500 error on production with load balancer having redis as cache driver.

$workspaceAdminRole->givePermissionTo(['workspace view']);

However, this works fine
$workspaceAdminRole->givePermissionTo([Permission::where('name', 'workspace.view')->first()]);

same fatal memory error is occurs for the controller middleware
$this->middleware('permission:workspace.list')->only('index');

Am I missing something for production env?

Steps To Reproduce

...

Example Application

No response

Version of spatie/laravel-permission package:

6

Version of laravel/framework package:

11

PHP version:

8.2

Database engine and version:

MySQL

OS: Windows/Mac/Linux version:

Linux Ubuntu

@drbyte
Copy link
Collaborator

drbyte commented Apr 9, 2025

Can you post the actual memory error?
And your PHP-FPM memory_limit configuration setting value.

Sometimes developers have very high memory limits in dev environment but too low limits in their production server configuration.

@waleed1892
Copy link
Author

This is the actual error getting in logs
Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes) in /var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 414

I'm using application in a docker container having config file same for both prod and dev with 1024M memory_limit

@drbyte
Copy link
Collaborator

drbyte commented Apr 10, 2025

Peculiar.

How many records are in these tables?
model_has_roles
model_has_permissions
role_has_permissions
roles
permissions

@waleed1892
Copy link
Author

model_has_roles= 1924
model_has_permissions= 0
role_has_permissions= 7170
roles= 1800
permissions= 15

@waleed1892
Copy link
Author

Another thing to note is that I'm using team permissions creating role for each team.

@parallels999
Copy link
Contributor

maybe #2444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants