When do php static methods start taking up memory? Will different php processes share static methods?

WBOY
Release: 2016-09-15 11:15:07
Original
1543 people have browsed it

When do php static methods start taking up memory?

For example, a class

class Test { public static function test1(){} public static function test2(){} ... } 
Copy after login

I considered the following situations:

  1. When executing php code, static methods are scanned, regardless of whether they are included., they are too inefficient and should not be used.

  2. When Iinclude 'Test.php', will it scan the class and load the static method into the memory? At this time, all methods should be loaded into memory.

  3. If2is not true, should it be loaded into the memory when calling the methodTest::test1();? If loaded at this time, should only the current method be loaded, or all static methods of the current class?


Will different php processes share static methods?

As shown below

When do php static methods start taking up memory? Will different php processes share static methods?

Here is a master who talked about Nginx and Php-fpm processes and threads: https://segmentfault.com/q/10...

If this is the case, one Php-fpm process serves one client, but if the concurrency is too high, won't there be many processes? In terms of process communication, requests from different clients belong to different processes and should not affect each other. There should be a cache of static methods in the memory occupied by the process. However, if a client has multiple requests, read the article. It is a blocking single-thread model, so each request should wait until the last request is completed before starting execution. Will the cache of the static method be cleared at this time, or should it continue to be saved? If cleared, static methods should not be shared.

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!