Zend_Cache 反序列化 - 内存占用?

发布于 2024-09-10 14:31:44 字数 618 浏览 3 评论 0原文

我已经设置了 Zend_Db_Table_Abstract,因此它使用元数据缓存,然后使用 xhprof 进行分析以查看它使用了多少内存。

结果从 _setupMetadata 到 Zend_Cache_Core::load 的 34 次调用占用了 7mb 内存,其中大部分是通过调用 unserialize 使用的。

元数据缓存的配置是:

resources.cachemanager.db_metadata.frontend.name = Core
resources.cachemanager.db_metadata.frontend.options.automatic_serialization = true
resources.cachemanager.db_metadata.frontend.options.lifetime = null

resources.cachemanager.db_metadata.backend.name = File
resources.cachemanager.db_metadata.backend.options.cache_dir = APPLICATION_PATH "/../data/cache/db_metadata"

这是一个常见问题,还是我遗漏了什么?

I've setup Zend_Db_Table_Abstract so it uses metadata cache and then profiled with xhprof to see how much memory it uses.

Turns out 34 calls from _setupMetadata to Zend_Cache_Core::load use up 7mb memory, most of it being used by calling unserialize.

The configuration for the metadata cache is:

resources.cachemanager.db_metadata.frontend.name = Core
resources.cachemanager.db_metadata.frontend.options.automatic_serialization = true
resources.cachemanager.db_metadata.frontend.options.lifetime = null

resources.cachemanager.db_metadata.backend.name = File
resources.cachemanager.db_metadata.backend.options.cache_dir = APPLICATION_PATH "/../data/cache/db_metadata"

Is this a common issue, or am I missing something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不…忘初心 2024-09-17 14:31:44

由于您正在序列化对象,因此需要大量内存。
特别是 Zend_Db_* 对象。

在这里我们遇到了同样的问题,我们最终为您制作了自己的缓存系统。

您可以做的是定义睡眠/唤醒,以便从 Zend_Db_Table_Row_Abstract 中删除所有不必要的 ivar,但必须确保不破坏类不变性。

祝你好运。 :)

Since you are serializing object it take a lot of memory.
Especially Zend_Db_* object.

Here we had the same issue and we end up in making you own cache system.

What you can do is to define sleep / wakeup so that you remove all unnecessary ivar from Zend_Db_Table_Row_Abstract but you have to make sure to not break class invariant.

Good luck. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文