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 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看