Giter VIP home page Giter VIP logo

Comments (2)

NathanFreeman avatar NathanFreeman commented on July 25, 2024

Because a connection pool is used, the connections inside the pool will only be released when the program terminates.

from swoole-src.

GuillaumeBrook avatar GuillaumeBrook commented on July 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.