Coder Social home page Coder Social logo

Memory limit error about peridot HOT 9 CLOSED

djones8520 avatar djones8520 commented on September 16, 2024
Memory limit error

from peridot.

Comments (9)

brianium avatar brianium commented on September 16, 2024

@djones8520 I will definitely be taking a look at this. There are certainly some optimizations that can be made to scope. I don't have a solution off the top of my head, but I will look into this shortly.

Thanks for opening the issue :)

from peridot.

djones8520 avatar djones8520 commented on September 16, 2024

So, I found the handy clearProphet function on ProphecyScope and added that function call to any ProphecyScope children on $scope. That allowed the tests to pass locally at 128 MB (was failing). However, they still fail on circleci at the same limit.

Locally, I tested a few different limits and it fails at 127 MB. That seems like a pretty tight window. It got me wondering about the memory needed to run peridot and I didn't see any memory requirements listed. Is 128 not enough memory?

from peridot.

brianium avatar brianium commented on September 16, 2024

Hmmmm. That is a pretty variable requirement in my opinion. I will definitely acknowledge there could be some improvements to the shared nature of scopes with regard to this problem, but the memory requirement for just about any testing tool increases the larger the test suite. Can I ask how large your test suite is?

from peridot.

brianium avatar brianium commented on September 16, 2024

If it is a bit on the larger side, this article here seems helpful on bumping up your memory limit for PHP in a circle-ci environment

https://www.neontsunami.com/posts/running-laravel-through-continuous-integration-(ci)-using-circleci

from peridot.

brianium avatar brianium commented on September 16, 2024

Something to the effect of:

// circle.yml
machine:
  php:
    version: 5.4.21
dependencies:
  pre:
    - echo "memory_limit = 1024M" > ~/.phpenv/versions/5.4.21/etc/conf.d/memory.ini

from peridot.

djones8520 avatar djones8520 commented on September 16, 2024

We have about 800 tests at the moment. I'm not sure how that stacks up to the norm, but it doesn't seem too big.

from peridot.

djones8520 avatar djones8520 commented on September 16, 2024

I don't mind bumping up the memory limit of circleci, but we didn't want to raise it just because. If 128 MB is too small for tests, so be it, but if we're using too much memory in our tests for some reason, we'd rather fix that.

from peridot.

brianium avatar brianium commented on September 16, 2024

I hear you :)

I suspect scopes are too blame. The loader essentially builds a giant tree out of the entire suite, and with 800 tests, you end up with a decent sized tree. Throw a bunch of large scopes on those nodes and the memory requirement goes up. There might be a way to optimize how that scope is shared/set to prevent unnecessary bloat.

You might be able to free up some memory by running your tests concurrently as well. There is a peridot plugin for that you might try - it currently does not support Windows.

I will take a look into general scope optimization, and specifically the ProphecyPlugin to see if any optimizations can be made there.

Thanks so much for opening this :)

from peridot.

djones8520 avatar djones8520 commented on September 16, 2024

Sure thing. We ended up increasing the memory limit to solve the "issue." It may have been too low in general.

In case anyone is curious about the scope problem, we got a decent solution I think. Above I posted code that we have in our peridot.php config file. Inside the suite.end event, is:

$children = $scope->peridotGetChildScopes(); foreach($children as $child){ if(get_class($child) == ProphecyScope::class) $child->clearProphet(); }

This clears the variables created and prophecy predictions/other by our tests. suite.end event is after each describe section of the test. There is a test.end event, but that didn't work for use, since it seems to run before afterEach sections and we use those sometimes for asserts that each test in the describe share.

This added event didn't cause any issues that we see, so it seems pretty solid. In fact, we discovered a few tests that were passing due to the "scope leak."

from peridot.

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.