Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103018 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43543 invoked from network); 1 Aug 2018 19:59:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Aug 2018 19:59:34 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.220.170 mail-qk0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:34296] helo=mail-qk0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A8/81-14835-521126B5 for ; Wed, 01 Aug 2018 15:59:34 -0400 Received: by mail-qk0-f170.google.com with SMTP id b66-v6so13575751qkj.1 for ; Wed, 01 Aug 2018 12:59:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=k3+IFDLYyOCe806fuqgt8JiXA9afKJcHz6yDUGktPhI=; b=snyVKXiwEVAE5x3XtKWXaFYF2Bqmf8WvUs84uKa61d7mCfwCEVjy+K3sU1wwtNFpzd 1TW2Sid48tlWJpK0W3rGxTs3u21G4FStrHmsrjsNGGNIkwygZBsC0eYmIJicqNCPjIuX uUSzzbiaP79GQxQ+YM+eZTbpRWAx5wTEpvwbThsk3W6ElgWK1xdXPzIGh2R+A0JTa8xc UxRX8CQf9hnWd6e1eZddtm+BWKW+f52tXwamvUzf4n7HkG3Gc37esY80FCpmKDpILnOw o/fkzqF+yE3adqsKeUpFuvAJCbtcC3ixGbSa9B7DVR51GxvCJAPyjpqHQp0gvg2rYNq7 mPCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=k3+IFDLYyOCe806fuqgt8JiXA9afKJcHz6yDUGktPhI=; b=BgYy7GOPorU3arlxfAN4zdcTY2zsgnqekpRLGt8G2gI3vcDHVfOkFWMxPfSVjzCZGU fwzYq39o9ihtnrcyrUNTPMjkaW31LPWZU2e+Ng1zyu+5OOyVD+eByH8ye9oI4kXGiE1Q BOsxc2EcFNngFSDcHCGWr5Lk3RyW+89J1gQ75soaIHvVydmikREix9wucxG6Yi522ad6 8IODE0zlCDl5FfQL8AI7hmzlCnyLQEm3f7w5ThSOP8hrEoCuo9v0zZcvDntGv4aqP4DY VnXPSfG8dSuWal2BNvuUIuMZwq7Y3kvYJsYWa8p1s9NyL2QsTvPXRCoQlF7W817npJgi bo1w== X-Gm-Message-State: AOUpUlEKLBPNknTLbzSQ5sXlNms8dgXXMlIssZNWsBaWoHXgohzetXs5 NIvzDTPqfvwuFuu2uEMsoJWiJzVUiekqYLeX47Fsw0X+ X-Google-Smtp-Source: AAOMgpdQ6vVvTr6ibpa+8E7zGRAiTdnNMTSza5JIXEG7PkdFa9vuiNqjmYlUOBOJqeYTX1Q68mucn99AF2PjxNYPe2E= X-Received: by 2002:a37:288d:: with SMTP id o13-v6mr25367893qko.205.1533153570768; Wed, 01 Aug 2018 12:59:30 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 2002:a0c:ada6:0:0:0:0:0 with HTTP; Wed, 1 Aug 2018 12:59:30 -0700 (PDT) X-Originating-IP: [98.213.160.75] In-Reply-To: References: Date: Wed, 1 Aug 2018 15:59:30 -0400 X-Google-Sender-Auth: SZ1dz8S4nHuzF82z8WHl-E2-g4U Message-ID: To: Marcos Passos Cc: internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Array max size From: pollita@php.net (Sara Golemon) On Wed, Aug 1, 2018 at 2:41 PM, Marcos Passos wrote: > Whenever you look for more information about the maximum size of an array, > you find someone saying that "PHP arrays do not have a maximum size, but > the amount of memory available". However, I could not find any excerpt in > PHP documentation that supports that. > I would say that *AS A LANGUAGE*, PHP does in fact have no limit on array sizes. Period. Beyond that definition in the language specification, there come two limiting factors: 1. The hardware limitation of the machine running PHP. i.e. How much memory it has. This is the most practical answer for most users. 2. Implementation details of the PHP runtime. The reference implementation of PHP uses a uint32_t to keep track of the number of elements for quick and easy O(1) access. This may or may not limit the array to (2^32-1) elements, but it does certainly limit the functionality of count() when operating on arrays. I think documenting in the php.net manual (which refers solely to the reference implementation) a limit of (2^32-1) elements as an implementation detail is not unreasonable, but it's worthy of nothing more than a footnote on the arrays reference page. The answer in #1 about memory limits is FAR more salient to typical uses. -Sara