Saturday 15 January 2011

php - Why do references use more memory? -


Should not those scripts use less memory?

A function (& amp; $ Var); Uses more memory than the function ($ var); More as

and foreach ($ arr = $ k => & amp; $ V) foreach ($ k => $ v) Uses

for example $ var 24 uses MB. If I pass it by reference then it uses 27 MB

(unfortunately) < With the expansion inside the empress zend engine, I am referring to:

In PHP the reference is a means of accessing the same variable content with different names. They are not like Sea Points; For example, you can not make pointers arithmetic using them, they are not actual memory addresses, and so on. See what the references are for more information. Instead, they are the symbol table nicknames Note that in PHP, the variable name and variable content are different, so the same content can have different names. The closest similarity is with the Unix filenames and files - variable names are directory entries, while the variable content is the file, references can be linked to hardlinking in the Unix filesystem.

I think comparing with a Unix file system is easy to understand. If you have many names for the file, then you will need additional storage to store those names.

No comments:

Post a Comment