Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107307 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 76829 invoked from network); 24 Sep 2019 08:47:27 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 24 Sep 2019 08:47:27 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id CCD012CD1C4 for ; Mon, 23 Sep 2019 23:26:17 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Mon, 23 Sep 2019 23:26:17 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id u8so1664703iom.5 for ; Mon, 23 Sep 2019 23:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=1mk1NKfzUoG08MX9xa+HSRuWzTfcyFiUqxeZYKHbE1c=; b=POwPBc8zdnP0XvECP83B5/sbIVfcJ2rOG1X79jsSuG+GNui23NGRPUIZY8W9jUkyN4 odo2YwDHTxyr/qgvzgf9dJ3i6ATWNERyDxpMQApQzSWhyzDrlaS1jI9RvSnjmKCdljDh awgd5mUgZpsuce2kOKk3tljiC+1+B9MpQ2Dwkr4Kd7Z7g60WN1eR/fgHIzXAw1B8NFr8 QtwvfEVGHMAUyMbt4Ena7IuaebLU6L4hYSNjsVHKxkVjNRkBlsQU+btYhU0qafkO/r/u 8G6qVJEKlRfOT0mtyp6DQkbcA1J0E9MdqzJOBMJcwExOwudRRN4Cq2V2lFhTJ4c9LMPm TKCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=1mk1NKfzUoG08MX9xa+HSRuWzTfcyFiUqxeZYKHbE1c=; b=QN8d8fql071vgU1z4b9Gd/mZWQCgXAH//BIECZ6/G72BRdJaipfyffCoFNIpNrpLlN sffvAQnuasNsYKPpH+FSwx4dym7ZUzDVOFZapG9aRHSngS2uwastuFKu8ohvKs8WII4d 9TA1qvyeR2nvWutVL1R2rCvtGKOce4M0DnVsHUp6nqFn6hxFYBRcHgpsZSKu0/e2CNf8 4TzNpxgoVhB3ZdL5q9pMGflQt2h79ynro85Ncm567m1eFHLoqQH/wTGpmrRtWMgL/BMG Pe/VscemkiA17V/2XO5A3iIr3r70EDNBVuItSR3UniqMw9Za81GV7zDiUaiI7DJ+J3r9 vNJw== X-Gm-Message-State: APjAAAVOiRnFWYDvGbo+WhJA5P7CQ07k6h0YoGreun7lPycEJsBi/LiN pCnDseDW89NsL7ACJfQXZ0rK3/oOXWLGdLiAd9jIa7ddPZc= X-Google-Smtp-Source: APXvYqwYz8Z5ybY5eaXnavFPJNRsAVld7wDGn3QxbaZCDdcSr88r2lrmyVP7pIyUi5m8MhqBqBij2GgUnNm4GWET5YI= X-Received: by 2002:a02:ce2b:: with SMTP id v11mr1937172jar.134.1569306375904; Mon, 23 Sep 2019 23:26:15 -0700 (PDT) MIME-Version: 1.0 Date: Mon, 23 Sep 2019 23:26:04 -0700 Message-ID: To: "internals@lists.php.net" Content-Type: text/plain; charset="UTF-8" X-Envelope-From: Subject: Shutdown Memory Allowance (aka Soft Memory Limit) From: sarkedev@gmail.com (Peter Stalman) Hi Internals, When PHP runs out of memory, a fatal error is triggered and whatever shutdown functions or error handlers take over. However, in the case of error logging, or just logging in general, there often needs to be additional memory used to accommodate the final logging process. This can sort of be accomplished in userland a few ways: 1. Pre-allocating memory in a variable, such as the Yii2 error handler (http://bit.ly/2kLnpd2), but this requires wasting memory on every request. 2. Continuously checking the memory usage, but this increases code complexity needlessly and also wastes resources with constant checking. 3. A second process with its own memory allowance, but this also increases complexity and transferring the required data for logging would require serialization without using additional memory. I'm not sure how this would be accomplished. So I would like to suggest an option for setting a shutdown memory allowance, which would be the amount of additional memory allowed to be used by any registered error handlers or shutdown functions. I think a C implementation of this in PHP would be far more efficient than the userland implementionations I mentioned. Thoughts? Thanks, Peter