清除PHP正在使用的内存 [英] Clear memory being used by PHP

查看:83
本文介绍了清除PHP正在使用的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个有趣的问题.我正在使用PHPUnit,并且每次运行测试都会占用更多内存.即...

I'm running into an interesting problem. I'm using PHPUnit, and my tests take more memory every single time I run them. Ie...

2.25 MB

2.5 MB

3.0 MB

3.5 MB .......

3.5 MB .......

有人知道如何清除正在消耗的内存,有人可以建议我深入研究吗?眼前的问题是我的一些较大的测试用完了内存,仅继续增加PHP中的最大内存分配还不够好...我需要知道为什么从命令行运行的PHPUnit测试会有内存在每次运行之间粘在一起"的用法.

Does anyone know how to clear out the memory that is being consumed, and can anyone advise me on exploring this in depth? The immediate problem is that some of my larger tests are running out of memory, and simply continuing to increase the max memory allotment in PHP isn't good enough...I need to know why a PHPUnit test running from command line would have memory usage which "sticks around" between runs.

推荐答案

卡尔文,如聊天中所述,这是由于缺少重置功能.

Calvin, as per discussed in the chat, it was due to missing reset features.

测试时,我们必须确保测试环境一致,以便能够获得准确的结果.计算是输入/输出,因此我们应该使用 PHPUnit中的固定装置重置存储以防止出现内存"像这样的泄漏".

When testing, we must ensure that the test environment is consistent so that we're able to get accurate results. Computing is Input/Output and hence we should use Fixtures in PHPUnit to reset storage to prevent "memory leaks" like these.

这篇关于清除PHP正在使用的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆