From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.help Subject: Re: How to debug memory leaks Date: Fri, 26 Mar 2021 17:11:02 +0100 Message-ID: References: <87pmzmihyj.fsf@robertthorpeconsulting.com> <83lfaaot5h.fsf@gnu.org> <83k0puorpb.fsf@gnu.org> <83ft0hq4wb.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15838"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 26 17:11:34 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lPp3d-00040k-VQ for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 26 Mar 2021 17:11:34 +0100 Original-Received: from localhost ([::1]:46186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPp3d-0007KV-0E for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 26 Mar 2021 12:11:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPp3F-0007IW-Ry for help-gnu-emacs@gnu.org; Fri, 26 Mar 2021 12:11:09 -0400 Original-Received: from mail-oln040092073058.outbound.protection.outlook.com ([40.92.73.58]:24353 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPp3D-0005mE-Lj; Fri, 26 Mar 2021 12:11:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dn93p3uQQTOEIr2CL+poWh33fPpe6WHCx2X1zomKA5je3c8SwO42/CtHTazozdRSGkxa1zAx9/ifHO09wwGHzAbe2EShBy8pFw9N05KMjCgBUULeFhswwAWvU4WaU5GsB+J5HuOFvGwS5uEFENTZJKa0c0SkompU/thd2MVDsLf587utnh3Ih36Z3wGWWJjvMhXifaDC9ehLaDy7jKF25HaOaYzNeOzd4yUim78RA3fa+4oCw1bHXn58pzdQwM6St70bctTJwrYUPVhM9W7JW1rjTPT4x7y+7t/QcruXefFVMWhovKf8Fa1lNIfQ2pHQLWdQLlnm3KHJ+gpT74pXUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eJ1iDW/TrKb038iuWVnDS2kqo5nkkP0ANacma7qhmEU=; b=lDDC6KEmnhdOtrJw6zR5DzFbdLlku83dPQBUonb9p2sQiIPNfJ8YQ3x8lZ4m5Uc6jo2w9JWLZNJxKG/zK0p98a2mcj3D6sKWXVtp7pWyXc/8nAOyF+eGwB2B3Y0kEpnFWOdTo3yJh3eKJtzy5IH3vz1VWneOPgWDxGYlNYC1TYKmiGq6CdjAJ34OC24CjQmLwSs1pimBTeoyoUUth1cH6frc645vyH6/hr1QsP27UbVMiA21HJdc67SXaQJ7KzC2sj0HeVvIrbYybJDzYcVEeW9k5bx9HaDQa/rAiUl218Pw6ZJdlttWBsHpd9v4GM5ctKZdI53xOQ/VN3WIhMz3dQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eJ1iDW/TrKb038iuWVnDS2kqo5nkkP0ANacma7qhmEU=; b=I6mOV0rqM4x5dr4n9CI4OvvmZappYMG6+P3JHkrOUWQASta+3VTaQvov9LwGkHwBF4k+qp/hFbn5CMrvqAWYBKoFPBcAMfrTBRwU3BZ8mGzAV6pSBZr6p+GaCbSLWqRk77EWGmrhksSxnqYt2Vhc2zMzW8Tz1xcFZEiV8GxwUVZ5eTqXhoXUPoKLSe5Ls8ajCe+FGiZ+uy1v0COYolCCEilnoVmuPYrjrc0FCh2+/ToHq9gFXFlQNxQwjw5VB8jtIGSInsEsBlUK2cHCGmHIuL0BSWzQ8f03SRq6v81iZoKKV5k5cNj+elXAgtQieS0XSsnGcXF8JacjSBWIaxseQg== Original-Received: from VI1EUR04FT047.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0e::53) by VI1EUR04HT184.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0e::286) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.29; Fri, 26 Mar 2021 16:11:03 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2a01:111:e400:7e0e::51) by VI1EUR04FT047.mail.protection.outlook.com (2a01:111:e400:7e0e::81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25 via Frontend Transport; Fri, 26 Mar 2021 16:11:03 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:84AFD0E03E3DFCDF9EA1F872ABAC6763B61623B241E20F263920C8A22BBF0BE9; UpperCasedChecksum:89B5F9FFF1D04DF26A0311D362D88D7321A7CCD652E936A0F68B6CEE167CD0E5; SizeAsReceived:7798; Count:46 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::2103:e705:bc0c:5a8b]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::2103:e705:bc0c:5a8b%6]) with mapi id 15.20.3977.025; Fri, 26 Mar 2021 16:11:03 +0000 In-Reply-To: <83ft0hq4wb.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 26 Mar 2021 19:03:00 +0300") X-TMN: [Key3enpJ9VhChhIyR0hbIfWnkDm7/ByM] X-ClientProxiedBy: AM6PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:20b:92::31) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87blb5lwtl.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (90.230.29.56) by AM6PR04CA0018.eurprd04.prod.outlook.com (2603:10a6:20b:92::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25 via Frontend Transport; Fri, 26 Mar 2021 16:11:03 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 9eddddb8-0883-47c8-cdb9-08d8f071c105 X-MS-TrafficTypeDiagnostic: VI1EUR04HT184: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +uMljDwHFQ4hQyJMHhRUcdcskKioZs21FOQNv/aCq8DJi/vyXY7xoAuIa8pY5W2b3KaqOUnrUxD2sU6o9kNdtC2X9GhJeWczOnqsaRUlYuNkw744wyK6WszelCcHCxJRwN3rV7jUGUj1U2KYVQF//Atv0O6MYSxpk85Ji97rasB4bES9qPkL1rOCB48EX1b7+2A0NUbGkYkxJNnLC7VyM1mbR7Ng/t2OsqxYLYK4GxNVhddlwpxLuwO8tm9rmCR+KKyvigxL2Y7zJspX1/1ogItPPx1Y6YVQ7ff11b/E9ZRURH6JTBJngtaDV0Ue8tsSz58oeDBWtIu8FGPfyznGA9piQlZ+nnIlmRzrGoWvXFAE3OoMeOCOGp1m5WZnFZSQdGaqj+Hf9SRp9zCX2fI0Zw== X-MS-Exchange-AntiSpam-MessageData: JtV+Iokr8duVi9DIWlg/dOOl9xMaiw3DL0tvq4aCDPXY1F6sA/EIIkbW04oouexwC1Q2M9fgtJCl8ky4tGF4zzTDPDLx+R+VmCIlM8KYcxRudnKw2vz6aLQW4xg0eBYS8Pk8i/ER8bnBjH/SaPyziw== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9eddddb8-0883-47c8-cdb9-08d8f071c105 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2021 16:11:03.6006 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VI1EUR04FT047.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1EUR04HT184 Received-SPF: pass client-ip=40.92.73.58; envelope-from=arthur.miller@live.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128650 Archived-At: Eli Zaretskii writes: >> From: Arthur Miller >> Cc: help-gnu-emacs@gnu.org >> Date: Fri, 26 Mar 2021 16:53:58 +0100 >> >> >> Yes, but GC can't know if I don't need undo history, right >> > >> > And neither do you. GC compacts the undo history, though, and frees >> > the slack. >> >> Ok, good if GC compacts the undo, but I could explicitly wish/know >> sometimes that I could "freeze" the undo. I could just put on my own >> interactive command that does this instead of using >> M-: (setq buffer-undo-list nil), but there could be some other stuff >> based on mode, like eshell or term or I don't know what. That could help >> GC. > > You will have to come up with more specific ideas, the above is too > general to be useful. If you suggest that some modes don't need undo, > then I don't think I agree. No, no, I don't mean that some modes don't need undo. I mean, if I am working in a buffer, say some C file, and I think Emacs get sluggish, I could do some M-x clean-buffer and have it setq bunch of variables to nil, amongst them undo so GC can collect them. It is just that these variables might be different depending of type of buffer, active modes etc. I can of course do my own interactive command. But it is maybe better if there was a "standard" hook which mode writers can use, and standard command, so users like me don't need to write their own. >> >> or old text in eshell buffer? >> > >> > Delete it, and it will be free'd. >> >> Yes, so that is what I am saying; a hook to put all kind of various >> "delete" stuff for various modes so we can run interactive command, say >> "clean-buffer" or whatever, and it will run the apropriate "deletes" and >> maybe other stuff based on mode. > > You have post-command-hook already; if you want to keep only a small > part of a shell buffer, you can use that hook to delete the old > stuff. This is clearly specific to your use patterns, though. Ok, I didn't know I can use post-command-hook for that. I'll try and play with it. Thanks. > And after all that, please keep in mind that in all the reports about > multi-GB memory footprints that people complained about, the actual > memory used by Lisp objects (what GC can free) was quite small, almost > negligible. The real problem, whatever it was, wasn't with GC not > freeing enough. To be honest, I don't really think it is very much needed, more of a "in case of" thing. Lately I haven't experienced any memory problems with Emacs, and it feels fast and responsive as ever before. So well done job there. >> Just as a note: no idea if you have found the memory leak or not, the >> big one that everyone was repporting few weeks ago, but I haven't >> experienced any leaks or slugishness with lately builds. I guess you >> found it? :). > > Not really. We fixed a problem where fiddling with some GC-related > options could cause Emacs stop calling GC, but that's all. Ok, seems like it works well now.