From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [IPv6:2a01:4f8:1c0c:6b10::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id DA3BB1F44D for ; Wed, 28 Feb 2024 13:28:54 +0000 (UTC) Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 928637EF52; Wed, 28 Feb 2024 13:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1709126918; bh=x0OTHKJgO9N9Zi1EpEkjHkauOIxbujPabkc8jUHEsXY=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=DD80k/Yefao4Obf4UxyuVQALE98h15VtpNvcPMYQcMBJaTCmXLSBYcq08VeLOkbfn rVdYpW78RL/3VhOdJOUWde+JDHbLHFwKZG8JBUHkdQegBwS3ntxACqcmA9m56vGPPd m8YNSAHxVQJacJM9NHSv0dN4toUbxA+XMXD1edS4= Received: from s.wrqvtbkv.outbound-mail.sendgrid.net (s.wrqvtbkv.outbound-mail.sendgrid.net [149.72.123.24]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 0DEE17D5D0 for ; Wed, 28 Feb 2024 13:28:32 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=fm9KCM+S; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=RJozL3CSznYj1SJxZWgroOmDeEHf82l1bNL46XwmE3g=; b=fm9KCM+S6OiCZhYjWSKd9YQ4rLcnG2qgNLbAbI0Bx2VOmIK1BMnl+2VFIzIEfvVHT/Of GJ0U0gWtWy+ZQrnsWfsWac8s5BjqE6gzSjsKxHi9lPAwi4XIIgZY9xt9Ew4B0H0MGMKv9i 0DiYblmDND6GJyTAIDgLaIT4UwkRkSlrDUXj9Q2CZfd5loirfgeC1IZJHxxduloUbJDzR5 VPdhVkfs8zBO54BLRDUXYkzma4TDtNKNSo0LCYwzsw+B+FR4G3fO+FjFuJtHxp7Z+/EdZN Q9wd3L8gB1Mr8jj/f4Wi/hypK+0rIEoEkpyPjfqUKjFskqiNHb+fqluquXnV2pBg== Received: by recvd-767c65dbff-gpds4 with SMTP id recvd-767c65dbff-gpds4-1-65DF34FF-9 2024-02-28 13:28:31.861027146 +0000 UTC m=+494005.506123321 Received: from herokuapp.com (unknown) by geopod-ismtpd-32 (SG) with ESMTP id RbwDP_t0Q7yQJD8QOY_NFQ for ; Wed, 28 Feb 2024 13:28:31.755 +0000 (UTC) Date: Wed, 28 Feb 2024 13:28:31 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 20311 X-Redmine-Issue-Author: MaxLap X-Redmine-Issue-Priority: Normal X-Redmine-Sender: byroot X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 93550 X-SG-EID: =?us-ascii?Q?Dq8GNIcVqP8cs5uR+EIAabfg3LE9XdC6dZ5KYNrMpf6VzBWG6HqArcu5raQjXL?= =?us-ascii?Q?IGTFdxKHUt7++67+KD54pNYXheirMcsUIf3sdgF?= =?us-ascii?Q?Riq06iJiqJsdkhe7dqe0WBP1=2FEEfz91vNqUXJ7B?= =?us-ascii?Q?GK74YdwzZWTIow2rRfsu5l5oH7A00Cub98QzELJ?= =?us-ascii?Q?69k7PSOT0kcKQ5MvXa1MuvNR6KFTMCoOrDErl1v?= =?us-ascii?Q?7OFR=2FZqylaSHKNkGgx6k8WOtYsFYUhvd1hYPZzJ?= =?us-ascii?Q?hBMvzTeB4Gj8=2FOjapY=2FqQ=3D=3D?= To: ruby-dev@ml.ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== Message-ID-Hash: DC6DSRXDF4NPSTP7VIGXR4JVWADH57PW X-Message-ID-Hash: DC6DSRXDF4NPSTP7VIGXR4JVWADH57PW X-MailFrom: bounces+313651-12dc-ruby-dev=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: "Ruby developers (Japanese)" Subject: =?utf-8?q?=5Bruby-dev=3A52070=5D_?= [Ruby master Bug#20311] Struct.new("A") memory leak? List-Id: "Ruby developers (Japanese)" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "byroot (Jean Boussier) via ruby-dev" Cc: "byroot (Jean Boussier)" Issue #20311 has been updated by byroot (Jean Boussier). I had a quick look at this using `ObjectSpace.dump_all`, and it appears that these classes are being retained in the VM root: ```ruby require 'objspace' 3.times do puts ObjectSpace.dump(Struct.new("A")) Struct.send(:remove_const, :A) end GC.start ObjectSpace.dump_all(output: File.open("/tmp/heap.json", "w+")) ``` ``` {"address":"0x102bc33f8", "type":"CLASS", .... {"address":"0x102bc3218", "type":"CLASS", .... {"address":"0x102bc3038", "type":"CLASS", .... ``` ``` $ rg -F '"0x102bc3218"' /tmp/heap.json 1:{"type":"ROOT", "root":"vm", "references":[..., "0x102bc3218" $ rg -F '"0x102bc33f8"' /tmp/heap.json 1:{"type":"ROOT", "root":"vm", "references":[..., "0x102bc33f8" ``` ---------------------------------------- Bug #20311: Struct.new("A") memory leak? https://bugs.ruby-lang.org/issues/20311#change-107049 * Author: MaxLap (Maxime Lapointe) * Status: Open * ruby -v: 3.3.0 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- The following code gives the impression of a memory leak. ``` 10.times do 5000.times do Struct.new("A") Struct.send(:remove_const, :A) end GC.start puts `ps -o rss= -p #{$$}`.to_i end ``` ``` 27868 35324 43400 51472 58676 66144 73764 81196 88512 95752 ``` Is there another location where the struct gets set that I need to clear up for the GC free the memory? Happens in 3.2.2, 3.2.3, 3.3.0, 3.3-head, ruby-head. -- https://bugs.ruby-lang.org/