Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pXSDR-0008Mw-Fy for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Mar 2023 19:34:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pXSDP-0002vf-UT for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Mar 2023 19:34:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pXSDP-0002vV-Km for pgsql-hackers@lists.postgresql.org; Wed, 01 Mar 2023 19:34:15 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pXSDM-00005W-U4 for pgsql-hackers@lists.postgresql.org; Wed, 01 Mar 2023 19:34:14 +0000 Received: by mail-wr1-x42a.google.com with SMTP id bw19so14361878wrb.13 for ; Wed, 01 Mar 2023 11:34:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=uzdBBksJI+MCVSYORrW36ZFhnZUQRKdEYPySyvgK5CA=; b=WNL58N0kI4HaT6mixjQ0UCokoBr39VsriNHL5P9vbA9kMcBGKFWGvrL7g29ZaPT9bo wPHYMqRlB8QWu4JEGXr78n17VKFya0JPzhq7RSgF0RcJUEtVjnyVLEJh0Os2eojv6Dpx duI6tyhPkAKIiOrtzFpZY/7Oj/hZrDbpysiWae2DZagnQ9Id0yR3i4cKg1mj+VqC0qSL UziddHnFOzw15UVaJLdyD8ffTvWhhPdz7Ne057KU8+QerukLEXYoQDlO/YS3hJSG4qS8 Lz8quycJGBRpnFU2Qr4e8wcc1NI56dw6+pdrkkZWo9GDvH9OaV28ehwAatvXF/eO4CXE qSEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uzdBBksJI+MCVSYORrW36ZFhnZUQRKdEYPySyvgK5CA=; b=LCaqlC7O+9E+lqyKvlrDiOMma4A8khq4ENuJvG8O099EyTXYm/C49dlslO3aAXoWr3 zc/CxQG5CMUrOKqXl62Y+FW5Rou70O62CHvhvgEIHm80JWaXKcYI/5ldhM3acLIcWRlm dAZdhQpdtdzfSBSi6XAgVccnDYthCN+615tnJhHdpKrcKktXfRW5QmdTAuZ/pm+8M17J 2KENL5coBBlWxOv+IU4tXH0owcMlgdRtqbRd7yXzYmDGdQAD0gVuc28AHveXES1SDcpR uW+fVJ2OVxFntFFeQVjYWqGU4tS81MCwoDsrZUTjiji5lA1IU6bqGPWjXK/YBicVfc7L ArJw== X-Gm-Message-State: AO0yUKWUHAMIfnRjOTtFYRsOPhkPDoUn4X5+rZcKpnS6XAtyM08F92eV RGCG6VrNyjvPE8T+dkQOap5dh3zF89S5M+SSFb4CnAD7oeLgRqF7nq9AhKewAoJdt+8D9AZKF5G 92VKnmMzxYDFTX+3duijwm4Cd9yKlqZiHOhV39GyIpxsyFT1Z7oryzgIUmvXTE6du7EgKGovS3x x1kdc6QUHP6xdMKuOpe6MrY6okdrLn0Iw5lOJa8XwP0P3HRyiYKzGpSfWR7pY0M6w= X-Google-Smtp-Source: AK7set/SICv8FhVXsfUI6JZzss5l1WNfR79WZ7IuLpkPq1AFeLF/AMFCJ26o+MUB4ngugUWTOFcH2Q== X-Received: by 2002:adf:e505:0:b0:2c8:a6ea:c00c with SMTP id j5-20020adfe505000000b002c8a6eac00cmr6668748wrm.69.1677699251053; Wed, 01 Mar 2023 11:34:11 -0800 (PST) Received: from [10.137.0.17] (ip-86-49-228-162.bb.vodafone.cz. [86.49.228.162]) by smtp.gmail.com with ESMTPSA id u10-20020a7bc04a000000b003e876122dc1sm422597wmc.47.2023.03.01.11.34.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Mar 2023 11:34:10 -0800 (PST) Message-ID: <8980879f-1a7a-87f0-3967-e0b8e2b3948c@enterprisedb.com> Date: Wed, 1 Mar 2023 20:34:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: Memory leak from ExecutorState context? Content-Language: en-US To: Jehan-Guillaume de Rorthais Cc: pgsql-hackers@lists.postgresql.org References: <20230228190643.1e368315@karst> <45d453c8-b2d3-b477-36eb-32fdf4455f3c@enterprisedb.com> <20230301184840.0a897a80@karst> <20230301190944.56ed0665@karst> From: Tomas Vondra In-Reply-To: <20230301190944.56ed0665@karst> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/1/23 19:09, Jehan-Guillaume de Rorthais wrote: > On Wed, 1 Mar 2023 18:48:40 +0100 > Jehan-Guillaume de Rorthais wrote: > ... >> You'll find some intermediate stats I already collected in attachment: >> >> * break 1, 2 and 3 are from AllocSetAlloc, break 4 is from AllocSetFree. >> * most of the non-free'd chunk are allocated since the very beginning, before >> the 5000's allocation call for almost 1M call so far. >> * 3754 of them have a chunk->size of 0 >> * it seems there's some buggy stats or data: >> # this one actually really comes from the gdb log >> 0x38a77b8: break=3 num=191 sz=4711441762604810240 (weird sz) >> # this one might be a bug in my script >> 0x2: break=2 num=945346 sz=2 (weird address) >> * ignoring the weird size requested during the 191st call, the total amount >> of non free'd memory is currently 5488MB > > I forgot one stat. I don't know if this is expected, normal or not, but 53 > chunks has been allocated on an existing address that was not free'd before. > It's likely chunk was freed by repalloc() and not by pfree() directly. Or maybe the whole context got destroyed/reset, in which case we don't free individual chunks. But that's unlikely for the ExecutorState. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company