首页
下载
文档
问答社区
视频
捐赠
源代码
AI 助理
赞助商
CRMEB
Apipost
腾讯云
微擎
禅道
51Talk
商业产品
Swoole AI 智能文档翻译器
Swoole-Compiler PHP 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
一个生产者协程通过channel让多个消费者协程消费的代码,内存不断上涨
### 问题描述 内存不断上涨,直到一个比较大的值。 ### Swoole版本,PHP版本,以及操作系统版本信息 ```bash swoole Swoole => enabled Author => Swoole Team <team@swoole.com> Version => 4.5.3RC1 Built => Aug 29 2020 12:27:11 coroutine => enabled epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled openssl => OpenSSL 1.0.2k-fips 26 Jan 2017 http2 => enabled pcre => enabled zlib => 1.2.7 mutex_timedlock => enabled pthread_barrier => enabled futex => enabled async_redis => enabled Directive => Local Value => Master Value swoole.enable_coroutine => On => On swoole.enable_library => On => On swoole.enable_preemptive_scheduler => Off => Off swoole.display_errors => On => On swoole.use_shortname => Off => Off swoole.unixsock_buffer_size => 8388608 => 8388608 ``` ```bash Zend Engine v3.4.0, Copyright (c) Zend Technologies ``` ```bash Linux localhost.localdomain 3.10.0-1127.18.2.el7.x86_64 #1 SMP Sun Jul 26 15:27:06 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux ``` ```bash specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper target: x86_64-redhat-linux configure: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ``` ### 相关代码 ```php <?php \Swoole\Coroutine\run(function () { $jobCh = new \Swoole\Coroutine\Channel(1000); for ($i=0;$i<100;$i++) { \Swoole\Coroutine::create(function () use ($jobCh) { while ($job = $jobCh->pop(5)) { var_dump($job); } }); } while (true) { sleep(3); $jobCh->push(1); } }); ``` ### 你期待的结果是什么?实际看到的错误信息又是什么? 期待内存消耗比较小与稳定,我看到内存消耗不断上涨,知道200MB左右才停止下来。
发布于4年前 · 6 次浏览 · 来自
提问
天王盖地虎
### 问题描述 内存不断上涨,直到一个比较大的值。 ### Swoole版本,PHP版本,以及操作系统版本信息 ```bash swoole Swoole => enabled Author => Swoole Team <team@swoole.com> Version => 4.5.3RC1 Built => Aug 29 2020 12:27:11 coroutine => enabled epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled openssl => OpenSSL 1.0.2k-fips 26 Jan 2017 http2 => enabled pcre => enabled zlib => 1.2.7 mutex_timedlock => enabled pthread_barrier => enabled futex => enabled async_redis => enabled Directive => Local Value => Master Value swoole.enable_coroutine => On => On swoole.enable_library => On => On swoole.enable_preemptive_scheduler => Off => Off swoole.display_errors => On => On swoole.use_shortname => Off => Off swoole.unixsock_buffer_size => 8388608 => 8388608 ``` ```bash Zend Engine v3.4.0, Copyright (c) Zend Technologies ``` ```bash Linux localhost.localdomain 3.10.0-1127.18.2.el7.x86_64 #1 SMP Sun Jul 26 15:27:06 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux ``` ```bash specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper target: x86_64-redhat-linux configure: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ``` ### 相关代码 ```php <?php \Swoole\Coroutine\run(function () { $jobCh = new \Swoole\Coroutine\Channel(1000); for ($i=0;$i<100;$i++) { \Swoole\Coroutine::create(function () use ($jobCh) { while ($job = $jobCh->pop(5)) { var_dump($job); } }); } while (true) { sleep(3); $jobCh->push(1); } }); ``` ### 你期待的结果是什么?实际看到的错误信息又是什么? 期待内存消耗比较小与稳定,我看到内存消耗不断上涨,知道200MB左右才停止下来。
赞
0
分享
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
评论
2020-09-03
鲁飞
你怎么查看的内存占用?
赞
0
回复
微信公众号
热门内容
作者其它话题
- 自定义进程内多个监听信号的协程未被逐个唤醒
暂无回复的问答
- CodeGalaxy K3s 轻量集群节点之间如何实现负载均衡
- 关于openssl CURL WARNING swSSL_connect: SSL_connect(fd=69) failed. Error: error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small[1|394]
- 多个模型如何进行事务异常回退?
- websocket开启wss报错
- 协程tcp服务器如何使用多进程?recv()方法接收信息,打印出来的pid一直是同一个。没用使用到多进程啊。