From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9875 invoked by alias); 27 Aug 2003 16:50:45 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 9843 invoked from network); 27 Aug 2003 16:50:43 -0000 Received: from unknown (HELO mailhub.lss.emc.com) (168.159.2.31) by sources.redhat.com with SMTP; 27 Aug 2003 16:50:43 -0000 Received: from emc.com (usendtaylorx1l [10.243.42.21]) by mailhub.lss.emc.com (Switch-2.2.5/Switch-2.2.0) with ESMTP id h7RGocC27142; Wed, 27 Aug 2003 12:50:38 -0400 (EDT) Message-Id: <200308271650.h7RGocC27142@mailhub.lss.emc.com> To: Kevin Buettner cc: Josef Wolf , gdb@sources.redhat.com Subject: Re: Why malloc() when target code is executed? In-Reply-To: Your message of "Mon, 25 Aug 2003 11:25:31 PDT." <1030825182531.ZM9704@localhost.localdomain> References: <20030822204844.GC14466@raven.inka.de> <1030825182531.ZM9704@localhost.localdomain> Date: Wed, 27 Aug 2003 16:50:00 -0000 From: David Taylor X-SW-Source: 2003-08/txt/msg00301.txt.bz2 > Date: Mon, 25 Aug 2003 11:25:31 -0700 > From: Kevin Buettner > > On Aug 22, 10:48pm, Josef Wolf wrote: > > > I just noticed that ``print printf("Hello\n")'' call malloc() on the target > > to allocate the memory for the string. AFAICS, this memory never gets freed. > > Is there any reason not to allocate this memory on the stack? This would > > avoid this memory leak. In addition, this would make it possible to use this > > feature on embedded systems which often have either restricted memory or > > even dont have malloc() at all. In addition to what Kevin said, if you're truly worried about the memory leak, you can use a debugger convenience variable -- that way you have the address and can free it: set $hello="Hello\n" print printf($hello) print free($hello)