GithubHelp home page GithubHelp logo

Comments (3)

epashkov avatar epashkov commented on July 23, 2024

I had tried to add __destruct method like this

public function __destruct() {
    unset($this->document);
}

to class https://github.com/handcraftedinthealps/ElasticsearchBundle/blob/5.x/Event/PrePersistEvent.php but it still leaks.

from elasticsearchbundle.

alexander-schranz avatar alexander-schranz commented on July 23, 2024

I think this could be more a listener which listen to the PrePersistEvent event. Also PHP is not the best for importing large amount of data but you could work agains it by using gc_collect_cycles method if you read from doctrine also make sure the clear the doctrine manager sometimes e.g.::

$counter = 0;
foreach ($dataList as $data) {
     ++$counter;

     // create and persist documents here:

     if (0 === $counter % 100) {
         // clear also the entityManager if used
         $entityManager->clear();
         // call garbage collector manually
         gc_collect_cycles();
     }
}

Also make sure you doing imports in prod environment under dev and debug symfony collecters are active which will collect all events so it normally there that the memory usage increases and grow, so memory can only be tested when running under app_env=prod with app_debug disabled.

from elasticsearchbundle.

epashkov avatar epashkov commented on July 23, 2024

@alexander-schranz Thanks for response. Think you are right about PrePersist Event. Seem that gc_collect_cycles() is not working as well in my case. Really in production environment memory usage increases less. It's quite satisfactory for my needs. Thanks a lot for clarifications.

from elasticsearchbundle.

Related Issues (8)

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.