From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 55CD63858D35 for ; Thu, 25 Nov 2021 18:21:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 55CD63858D35 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-161-hY_LI7ZUNkCLenAq79dEjA-1; Thu, 25 Nov 2021 13:21:27 -0500 X-MC-Unique: hY_LI7ZUNkCLenAq79dEjA-1 Received: by mail-qt1-f197.google.com with SMTP id p7-20020a05622a00c700b002b2f6944e7dso7462080qtw.10 for ; Thu, 25 Nov 2021 10:21:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:organization:in-reply-to :content-transfer-encoding; bh=C9lMJxOyNicL+QeBH6Z7O8dCRKiz+zeOr6wnB9rNpPI=; b=KAljI0lSQMD9+ZHp7+ouX5/NRsQ37qP1JrbdHk6DQbSyn7H3j8H8WZkPkcraPtLgrx bYZHzD3PGgqzQr/2gChy6gjGPgCp3FzEN5ytmqMezoWVuHZXN+8ZVDfMHrKcUN9OgQz8 gypo8cBZ6YWzN04Q7bmxdemW23vuyslRrwFawwlH7T3BTKfJzDfDoeADzRI7egu7MXO9 HtbIDCJAGmjZ7TiPuQ3kjLW9ZliWh544bq4+Z6wDNXfOBagrSZ56lwq8m5/SyF4Te023 xLmWPUoaYQVYEswvVttmV3vGbQC/G8pAndTwQimw0jTBlT1o6o+5SbuubqC/9RYta4tY T+YQ== X-Gm-Message-State: AOAM531Wu5BytMtHQbMz5XiP/k0M2cWF9R0e9SJ+4F70ACDVMpWQKiN+ UthEfwD/ZDwlpnCkMItLZkDV7Ml+KsqDXuP7AODtc4tCKDuM4vQ4r6Uqu9DPkXM64f6X2Fi/Hyt dBiSmzxRyaTamew7uFf0= X-Received: by 2002:ac8:5809:: with SMTP id g9mr19221458qtg.273.1637864486722; Thu, 25 Nov 2021 10:21:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpM/14w5x8igLtoYWv1dfdTq24SsR4ZMQ1n0xl1lYWtuo+OIPEKA9oAjBQ2kbqUTdNyO7XTg== X-Received: by 2002:ac8:5809:: with SMTP id g9mr19221437qtg.273.1637864486584; Thu, 25 Nov 2021 10:21:26 -0800 (PST) Received: from [192.168.0.241] (135-23-175-80.cpe.pppoe.ca. [135.23.175.80]) by smtp.gmail.com with ESMTPSA id i6sm1953410qti.40.2021.11.25.10.21.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Nov 2021 10:21:26 -0800 (PST) Message-ID: Date: Thu, 25 Nov 2021 13:21:25 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: Excessive memory consumption when using malloc() To: Konstantin Kharlamov , Christian Hoff , libc-help@sourceware.org References: <560ed6888a62b21362cda5385655c3a84fd354b9.camel@yandex.ru> <56522c8f847ddd27fdffedecb516f778837f9e92.camel@yandex.ru> From: Carlos O'Donell Organization: Red Hat In-Reply-To: <56522c8f847ddd27fdffedecb516f778837f9e92.camel@yandex.ru> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Nov 2021 18:21:30 -0000 On 11/25/21 13:12, Konstantin Kharlamov via Libc-help wrote: > So there you go, you 10G of unreleased memory is a Glibc feature, no complaints > ;-P Freeing memory back to the OS is a form of cache invalidation, and cache invalidation is hard and workload dependent. In this specific case, particularly with 50MiB, you are within the 64MiB 64-bit process heap size, and the 1024-byte frees do not trigger the performance expensive consolidation and heap reduction (which requires a munmap syscall to release the resources). In the case of 10GiB, and 512KiB allocations, we are talking different behaviour. I have responded here with my recommendations: https://sourceware.org/pipermail/libc-help/2021-November/006052.html -- Cheers, Carlos.