Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112735 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 2921 invoked from network); 3 Jan 2021 18:14:21 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jan 2021 18:14:21 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 961EB1804DD for ; Sun, 3 Jan 2021 09:50:06 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=BAYES_05, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 3 Jan 2021 09:50:05 -0800 (PST) Received: by mail-lf1-f54.google.com with SMTP id l11so59427438lfg.0 for ; Sun, 03 Jan 2021 09:50:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ar+MjegvhrUnA9jg/zUi3QUr7qexfibDauxo9/NE5sg=; b=sureZxY5opLiBMKdNTy2O7xnOE2yvznsO+xml5vYIrdEljOETI9MNeydBWo0WakaTK Zc1FSv3F814a1ENOOWYy/zF5PJ1Lu3f44gEKD2RLI+Aco+gLi67bq0UCtpkdxVUygQW3 VI3H7T0TH28q4QjdPNgMJjj/DkrYuVux5Sp7G/TPwlOH+BE1+xDUgJoLG9QHchyb3+Xt gILoOdnF36ZtGZZxCB/h6JEmgW1lTN4nkjOa8a4sVgtk3xTpBjJzHha8Rngj9xvREzmO LPEXfdFIZoWSlODbcmSwvZJKIYwASZUlyFbPDDccRPsoneuIs7YP0zNH5O9V+9IeCnrr typQ== X-Gm-Message-State: AOAM533LZWQ911GgBQWkP9x2PowvTTi1taETohq+0yIbBoCkhFGhYiny 9pWAev5oL8r0pHtBOZEp045BrV86Q+fQSEQ5JncKQg== X-Google-Smtp-Source: ABdhPJxN18ye7GhULnd2YzYwbxVpEDKRtPau4d2jacVriS5WDwyY94X+NyDSmtwXciPQGHYnoBi/iYRlHcOry8+vU3c= X-Received: by 2002:ac2:5f58:: with SMTP id 24mr32053984lfz.302.1609696202922; Sun, 03 Jan 2021 09:50:02 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 3 Jan 2021 11:49:52 -0600 Message-ID: To: =?UTF-8?Q?Olle_H=C3=A4rstedt?= Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000005f2f8105b8029a9e" Subject: Re: [PHP-DEV] Does PHP ever stack allocate? From: pollita@php.net (Sara Golemon) --0000000000005f2f8105b8029a9e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Jan 3, 2021 at 10:37 AM Olle H=C3=A4rstedt wrote: > Thanks Sara! I realize I should have been more precise: Can PHP > allocate non-reference counted memory that automatically is freed when > leaving scope, similar to what Go does with escape analysis? > It seems like you're conflating userspace variables and their underlying data storage mechanisms and while the two are related and have naturally similar semantics, they're not really the same thing and trying to generically talk about both at the same time is only going to add to confusion. If you're talking about userspace variables... Yeah. They're scope bound and destructed/freed on scope exit. Nearly every language does some form of this because to not do so would be leaky and awful. If you're talking about internal memory allocators, then the idea of "automatically freed" is a red-herring. It's an illusion created by some languages to cover up the quite explicit mechanisms in place to handle data lifetimes. PHP does its form of this as well using a combination of stack and heap allocators as appropriate. -Sara --0000000000005f2f8105b8029a9e--