Skip to content
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

Code Optimizations (Memory Usage) #40

Open
Zanaras opened this issue Mar 14, 2024 · 0 comments
Open

Code Optimizations (Memory Usage) #40

Zanaras opened this issue Mar 14, 2024 · 0 comments

Comments

@Zanaras
Copy link
Contributor

Zanaras commented Mar 14, 2024

Broadly speaking, there's not much point to over optimizing PHP as it's a just-in-time compiler that uses resources briefly to generate pages, except when it comes to the turn scripts. These scripts are run on the command line which means they're not subject to execution or memory limits as much as those ran through the web browser.

PHP itself will start to struggle when it's handling too many objects in memory, which is why a lot of the bulk processing is done through iterators. $doctrine->clear() is good for releasing a lot of stuff, but there's still a lot of left over variables that are never used again that we could clear up as well.

https://stackoverflow.com/questions/584960/whats-better-at-freeing-memory-with-php-unset-or-var-null has a good discussion on this but it boils down to:

$var = null;
unset($var);

This reduces the memory allocation then flags it cleanup. Don't use this inside loops though, as you're adding a bunch of extra memory work.

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

1 participant