For PHP Memory release issues
When you use the Phpexcel class, when you open a larger Excel data document, the fatalerror:allowed memorysize of 67108864 bytes exhausted (tried to allocate bytes) in example/admin/add_mysql.php on the line, the error is that the page memory is exhausted. Now let me take a look at the solution:
I think of two kinds, the first is to expand the memory that PHP can use:
1, in the php.ini file, modify the memory_limit:80m, the value of the actual situation of their respective decisions.
2, in PHP file, directly use In_set ("Memory_limit", "80M") to modify the memory limit.
The above situation only applies to local and virtual host, on the general space server or development platform is basically not allowed, let me say the second, as far as possible to reduce the page PHP execution memory consumption:
Use the unset () statement.
1, release variables: Online There are many use cases are used for variables, in fact, but in this case, when you unset a variable, it takes up the memory does not return to the system, but is occupied by the symbolic variable, (detailed can Baidu, there are many explanations).
2, release the object: especially when using the Phpexcel class, read a relatively large file, its objects will occupy a large amount of memory, for example:
Operation Result:
When we use unset:
Operation Result:
wow! , it is surprising that the release of variables will not reduce space, but the release of the object is very obvious, compared to a total of less than 33 million bytes, hoping to help people solve the problem, for the reasons I am not very clear, I hope the master can explain.