Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何解决条令集合中父/子自引用依赖项的内存泄漏_Php_Symfony_Memory_Memory Leaks_Doctrine Orm - Fatal编程技术网

Php 如何解决条令集合中父/子自引用依赖项的内存泄漏

Php 如何解决条令集合中父/子自引用依赖项的内存泄漏,php,symfony,memory,memory-leaks,doctrine-orm,Php,Symfony,Memory,Memory Leaks,Doctrine Orm,我的身体正面临着一个非常微妙的内存泄漏 我正在运行一个PHP守护进程,一旦加载了一个集合,其中的实体就永远不会从内存中释放出来。因此,我有一个小的,但不断增加的内存消耗,导致内存泄漏。我不知道怎么解决:) 详细信息 我们所说的实体是这样的(仅限相关属性和方法。完整代码): 在addChilDependency()和addParentDependency()方法中,存在当前内存使用的转储。以下是一些结果: "[Job::addChildDep] () before adding to childs

我的身体正面临着一个非常微妙的内存泄漏

我正在运行一个PHP守护进程,一旦加载了一个集合,其中的实体就永远不会从内存中释放出来。因此,我有一个小的,但不断增加的内存消耗,导致内存泄漏。我不知道怎么解决:)

详细信息

我们所说的实体是这样的(仅限相关属性和方法。完整代码):

addChilDependency()
addParentDependency()
方法中,存在当前内存使用的转储。以下是一些结果:

"[Job::addChildDep] () before adding to childs: 23.07"
"[Job::addChildDep] (61)before adding parent to given Job: 23.07"
"[Job::addParentDep] (61) before checking childs: 23.07"
"[Job::addParentDep] (61) before adding to parents: 25.17"
"[Job::addParentDep] ()before adding child to given Job: 25.17"
"[Job::addChildDep] after adding: 25.17"
...
"[Job::addChildDep] () before adding to childs: 25.17"
"[Job::addChildDep] (52)before adding parent to given Job: 25.17"
"[Job::addParentDep] (52) before checking childs: 25.17"
"[Job::addParentDep] (52) before adding to parents: 27.26"
"[Job::addParentDep] ()before adding child to given Job: 27.26"
"[Job::addChildDep] after adding: 27.26"
...
"[Job::addChildDep] () before adding to childs: 27.26"
"[Job::addChildDep] (98)before adding parent to given Job: 27.26"
"[Job::addParentDep] (98) before checking childs: 27.26"
"[Job::addParentDep] (98) before adding to parents: 27.26"
"[Job::addParentDep] ()before adding child to given Job: 27.26"
"[Job::addChildDep] after adding: 27.26"
...
"[Job::addChildDep] () before adding to childs: 27.26"
"[Job::addChildDep] (54)before adding parent to given Job: 27.26"
"[Job::addParentDep] (54) before checking childs: 27.26"
"[Job::addParentDep] (54) before adding to parents: 29.36"
"[Job::addParentDep] ()before adding child to given Job: 29.36"
"[Job::addChildDep] after adding: 29.36"
如您所见,当我使用时,
addParentDependency()
方法中的内存消耗有所增加

现在的问题不是内存消耗的增加,而是我无法释放它。

事实上,我使用了
EntityManager::detach()
(,and)和(然后使用启用)

我希望在守护进程运行期间内存会上下波动,但这不是真的,因为内存会上下波动

我还使用
EntityManager->getConfiguration()->setSQLLogger(null)
EntityManager->getConfiguration()->setSecondLevelCacheEnabled(false)
来保持低内存消耗。此外,我还设置了
cascade=“detach”,“refresh”
来分离子依赖项,但这似乎不起作用

因此,内存增量是由加载子依赖项的
集合
引起的

我想我正面临着一些与之相关的问题,但我真的不知道如何解决它们

您有什么建议吗?

您是否尝试过对“不再使用”变量调用unset()?除非你不销毁它们,否则垃圾收集器会把所有的东西都看作是被使用的变量,另一种方法是在一些较小的函数中减少你的代码,并且当该方法被执行时变量被破坏时,就不需要开始对内存UsAuSunStESET()进行剖析。我越来越确信,问题在于对象之间的循环引用导致它们成为“孤儿”,因此不是垃圾收集器收集的物品。。。我会做更多的测试来证明这篇论文,并试图找到一个解决方案。
"[Job::addChildDep] () before adding to childs: 23.07"
"[Job::addChildDep] (61)before adding parent to given Job: 23.07"
"[Job::addParentDep] (61) before checking childs: 23.07"
"[Job::addParentDep] (61) before adding to parents: 25.17"
"[Job::addParentDep] ()before adding child to given Job: 25.17"
"[Job::addChildDep] after adding: 25.17"
...
"[Job::addChildDep] () before adding to childs: 25.17"
"[Job::addChildDep] (52)before adding parent to given Job: 25.17"
"[Job::addParentDep] (52) before checking childs: 25.17"
"[Job::addParentDep] (52) before adding to parents: 27.26"
"[Job::addParentDep] ()before adding child to given Job: 27.26"
"[Job::addChildDep] after adding: 27.26"
...
"[Job::addChildDep] () before adding to childs: 27.26"
"[Job::addChildDep] (98)before adding parent to given Job: 27.26"
"[Job::addParentDep] (98) before checking childs: 27.26"
"[Job::addParentDep] (98) before adding to parents: 27.26"
"[Job::addParentDep] ()before adding child to given Job: 27.26"
"[Job::addChildDep] after adding: 27.26"
...
"[Job::addChildDep] () before adding to childs: 27.26"
"[Job::addChildDep] (54)before adding parent to given Job: 27.26"
"[Job::addParentDep] (54) before checking childs: 27.26"
"[Job::addParentDep] (54) before adding to parents: 29.36"
"[Job::addParentDep] ()before adding child to given Job: 29.36"
"[Job::addChildDep] after adding: 29.36"