duanchun1881 2017-12-30 21:55
浏览 91
已采纳

PHP如何管理加载到内存中的函数?

I was developing a PHP project recently using Laravel Framework. I was wondering whether the unused functions/methods of PHP get loaded into memory?. I read that one of pros of interpreted languages that they have automatic memory management. However, this has not answered my question of whether they are loaded or not. Does this automatic memory management handle the case mentioned?

What actually happens to my memory when I run:

php artisan serve

Is my whole Laravel project being loaded into memory?

If yes, Is it my responsibility as a developer to handle loading commonly used functions/methods?, furthermore; how do I decide where to store it or on which principles? (Note: You do not have to explain it all to me, just redirect me to a manual)

If no, where does it stores its methods or functions(i.e. cache, swaps to hard disk)?Moreover, are they stored as plain code or they have been interpreted already for further use?

  • 写回答

2条回答 默认 最新

  • doujiao0110 2017-12-30 22:01
    关注

    No it isn't all loaded into memory! That's because Laravel (like a great many PHP libraries and frameworks) uses an Autoloader that only loads what is needed to process the request, and only when it is needed.

    However, if you are using opcache, it will load the bytecode to opcache and that will remain in opcache until cleared

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件