GithubHelp home page GithubHelp logo

Comments (2)

JayBizzle avatar JayBizzle commented on May 17, 2024 1

Thanks for taking the time to explain 👍

from laravel-console-logger.

dmitry-ivanov avatar dmitry-ivanov commented on May 17, 2024

Hi, @JayBizzle !

Thanks for your kind words! :)

I'm reserving a bit of memory (while registering shutdown function), to have an ability to execute all required operations while handling "Fatal Error: Allowed Memory Size of ... Bytes Exhausted".

If you take a look on handling method:

public function onShutdown()
{
$this->reservedMemory = null;
$this->timeFinished = microtime(true);
$executionTime = round($this->timeFinished - $this->timeStarted, 3);
$this->logger->info("Execution time: {$executionTime} sec.");
$memoryPeak = format_bytes(memory_get_peak_usage(true));
$this->logger->info("Memory peak usage: {$memoryPeak}.");
$this->logger->info('%separator%');
$handlers = (array) $this->logger->getHandlers();
foreach ($handlers as $handler) {
$handler->close();
}
}

You'll see, that the first thing I do - is releasing that memory:

$this->reservedMemory = null;

And after that, I'm able to do all stuff, which you can see there below (which requires a bit of memory too).

PS: I've saw that trick at Monolog actually, so hat tips to Monolog :)
https://github.com/Seldaek/monolog/blob/master/src/Monolog/ErrorHandler.php

from laravel-console-logger.

Related Issues (11)

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.