Comments (2)
Because a connection pool is used, the connections inside the pool will only be released when the program terminates.
from swoole-src.
Actually, this is how mysqlnd operates.
Let's take the following example :
<?php
var_dump(memory_get_usage(true) / 1024 / 1024);
$pdoClient = new \PDO($dsn, $user, $password, $options);
$pdoClient->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); // doesn't matter anyway
$prepare = $pdoClient->prepare('select * from some_table'); // 400k entries
$prepare->execute();
$results = $prepare->fetchAll(\PDO::FETCH_ASSOC);
$prepare->closeCursor(); // doesn't matter anyway
var_dump(count($results));
unset($results, $prepare, $pdoClient);
var_dump(memory_get_usage(true) / 1024 / 1024);
Will print
int(2)
int(400000)
int(366)
In a php stateless app, that ok, we will retrieve our 366mb of memory at the end of the http request.
In a php stateful app, I don't manage to retrieve it.
Maybe the gc will do it's job sometimes but I doubt it.
I guess the only solution is to do the query outside the "Constant::EVENT_REQUEST" and say goodbye to my 366mb of memory... (it's better than saying goodbye to 366*number of workers though)
I didn't manage to find a solution yet to free this.
So indeed, it's not really linked to Swoole internals.
from swoole-src.
Related Issues (20)
- Cookie is truncated leading to a malformed/invalid cookie
- errno changes after wait_process, and causes incorrect WARNING messages HOT 1
- 优化下调试体验,xdebug下碰上io操作请不要直接切换协程 HOT 1
- Swoole\Table::set(): failed to set('36998'), unable to allocate memory HOT 4
- Uncaught Swoole\Error: cURL is executing, cannot be operated in HOT 8
- swoole 4.8-5.0版本使用redis异常 HOT 5
- Swoole CURL Flag causes SEGFAULT on PHP8.3 HOT 2
- Compile and install Swoole 5.1.1, run the make test command and output a large number of errors HOT 1
- abnormal exit HOT 3
- curl协程化无法通过curl_getinfo获取tcp连接时长等数据 HOT 4
- 编译报错 HOT 2
- 开启native curl后性能远不及未开启native curl HOT 2
- MySQL server fails connection at ./init of test HOT 1
- typo report: UNKOWN
- Urgent Request for 'curl' Bug Fix Release HOT 2
- swoole 5.1.1 线上运行一段时间后,容易出现假死现象 HOT 2
- PECL release of swoole 5.1.2 HOT 8
- syntax error near unexpected token `SQLITE,' HOT 1
- CURLOPT_SHARE option is not supported in Swoole 5.0.3 HOT 1
- Segmentation fault when calling blocking function inside coroutine 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.