M
M
Maxim2016-12-27 02:09:44
CMS
Maxim, 2016-12-27 02:09:44

Why does the native php engine use so much RAM?

There is a self-written php engine that consumes 30 MB of memory (the site itself is rather big). Moreover, the more functions I have in the func.php file (which is included), the more it affects memory consumption.
PHP includes are known to consume a lot of memory. But how does WordPress solve these problems? The same site in terms of structure on the WP-engine consumes 20-25 mb. But WP has a lot more includes and even more functions in functions.php.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xmoonlight, 2016-12-27
@xmoonlight

Скорее всего - проблема в многократном создании объектов класса без уничтожения тех, которые уже не нужны.
Но правильнее, будет использовать один экземпляр такого класса, поддерживающего многомерную структуру (дерево, стек и т.д.) с клонированием объектов внутри самого класса. Это значительно экономит память на выделение для каждого нового создаваемого подобного объекта класса.

B
Barnie Savington, 2016-12-27
@iwex

+1 for profiling.
But I can also add that look at autoload, it can help stackoverflow.com/questions/4737199/autoloader-for...
It can be anything, the optimizer is disabled, etc.)
In WP, by the way, there are many classes.

I
Ilya Karavaev, 2016-12-27
@Quieteroks

Moreover, the more functions I have in the func.php file (which is included)

Вы все функции храните в одном файле? Не думали что это функции занимают оперативную память? И чем больше вы пишете функций, тем больше он кушает памяти?
В WP Решается этот момент путем подключения меньшего количества файлов с функциями. Т.е. только те функции, которые нужны для текущего выполнения программы.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question