Comments (4)
异步 Server 在执行完 onMessage 回调之后协程就会退出,而 Coroutine Server 不同,同一个客户端连接总会有一个协程,因此 250 个客户端就会有 250 协程,需要占用内存。
from swoole-src.
异步 Server 在执行完 onMessage 回调之后协程就会退出,而 Coroutine Server 不同,同一个客户端连接总会有一个协程,因此 250 个客户端就会有 250 协程,需要占用内存。
250个协程不至于造成3倍的资源消耗吧
from swoole-src.
3倍只是巧合
from swoole-src.
并不是纠结于这个“3”,而是对于其中的消耗点想要更详细的了解
run(function () {
$i = 250;
while ($i--) {
Coroutine::create(function () {
while (true) {
sleep(1);
}
});
}
// 内存使用
$memory = memory_get_usage();
$memory = $memory / 1024;
$memory = $memory / 1024;
$memory = round($memory, 2);
echo '当前内存使用:' . $memory . 'MB' . PHP_EOL;
$channel = new Channel(1);
$channel->pop();
});
当前内存使用:3.84MB
而上面的实验结果差异为:54-18=36MB,不止协程占用的内存消耗
from swoole-src.
Related Issues (20)
- There is a memory leak defect on line 326 of the file /swoole-src/src/wrapper/http.cc.
- Calling $webSocketServer->task() is giving PHP Fatal error:Uncaught ArgumentCountError: Too few arguments to function [my_class_name]::{closure}(), 2 passed and exactly 4 expected HOT 1
- Second argument "Swoole\Server\Task $task" of the callback function of the event "onTask" becomes "nul"l when passed to a class constructor / function HOT 1
- 大并发的情况下,部分Worker,CPU一直占满100%,进程死循环 HOT 2
- macOS arm64 build failed with php 8.3.x HOT 1
- Http2 Server/Response does not support streaming (gRPC Server Streaming RPC / Bidirectional Streaming RPC)
- swoole6 设置dispatch_mode平均分配工作线程无效 HOT 3
- 多线程模式server达到max_request后进程终止;kill -USR1无法重启子线程 HOT 2
- php8.1.x+swoole-5.1.x+alpine3.1.7+xdebug 3.3.2 ,启动 hyperf 项目报错 HOT 1
- Worker freezes after restart when using worker_max_concurrency HOT 2
- Can not change settings for other opened port HOT 3
- Incorrect stats behavior when restarting workers
- v6多线程下 Swoole\Http\Response::create无效 HOT 1
- Async programming does not work in the magic __get() method HOT 2
- V6 chown函数异常 HOT 9
- Request header encoding error with exactly 16 lenght HOT 3
- Server-reload() does not terminate Swoole Timers, gracefully HOT 6
- [FIXED] Undefined constant "SWOOLE_SOCK_TCP" (MAMP PRO) HOT 33
- 一个在Swoole中使用协程化处理Oracle事务行锁中出现的奇怪问题 HOT 4
- Swoole\Process\Pool HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swoole-src.