From owner-freebsd-questions@FreeBSD.ORG Fri Sep 5 07:09:47 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 85F9816A4BF for ; Fri, 5 Sep 2003 07:09:47 -0700 (PDT) Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by mx1.FreeBSD.org (Postfix) with ESMTP id 13B6C43FCB for ; Fri, 5 Sep 2003 07:09:46 -0700 (PDT) (envelope-from freebsd-questions@m.gmane.org) Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 19vHHw-0001ol-00 for ; Fri, 05 Sep 2003 16:10:12 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-questions@freebsd.org Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19vHBw-0001js-00 for ; Fri, 05 Sep 2003 16:04:00 +0200 Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 19vHBT-0001Wa-00 for ; Fri, 05 Sep 2003 16:03:31 +0200 From: Jesse Guardiani Date: Fri, 05 Sep 2003 10:03:31 -0400 Organization: WingNET Lines: 66 Message-ID: References: <20030904124052.GD88888@happy-idiot-talk.infracaninophile.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: usenet@sea.gmane.org User-Agent: KNode/0.7.2 X-Mail-Copies-To: never Sender: news Subject: Re: process memory peak recording X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: jesse@wingnet.net List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Sep 2003 14:09:47 -0000 Matthew Seaman wrote: > On Wed, Sep 03, 2003 at 06:53:09PM -0400, Jesse Guardiani wrote: >> Howdy list, >> >> I'm a Sys Admin running FreeBSD 4.8-RELEASE >> servers. >> >> During a recent programming/installation >> project, I found myself wanting to know >> the peak memory usage of a given command/process. >> >> Is there any way to gather this information >> without recompiling an application with a >> sleep or wait statement at the (assumed) >> point of peak memory usage and then looking >> at the process with 'ps'? > > That depends on exactly how much time you've got to record the peak > memory usage. If it's going to be changing faster than you could > catch just by running ps(1) -- like: > > % ps -p NNN -o rsz > > where NNN is the pid of your process, then you're probably going to > have to interrupt the process somehow. You can do that by attaching > to the process using gdb(1), eg: > > % gdb PROGNAME NNN > > this will stop the process and leave you in the debugger at the > current program counter. You'ld have to create a break point when the > program calls malloc(3) or friends, continue running until it hits the > break point, step over the malloc call, check the size using ps(1), > and then continue running again until the next malloc(3) call. Repeat > until the program ends. See the gdb info pages for the gory details. > Nb. this whole thing with gdb(1) is going to be a great deal easier if > you have the source code to your program available and you can run an > unstripped binary. Doing such a trick on a stripped binary is getting > into real guru territory. Programs run a lot slower when attached in > a debugger, plus if the program makes heavy use of malloc, it's going > to get really tedious very quickly. Thanks for the reply, Matthew. Sorry for the misleading subject. I meant to post a different message under that subject. "process memory peak recording" should have been the subject for this message. I'm not sure if that was a bug in my human CPU or a bug in KNode... :) Anyway, I was really hoping that someone would write me back and tell me that there is already some voodoo kernel debugging switch that I could turn on to let me log/record peak memory usage for a particular process. I guess you're saying that isn't the case though, right? Sincerely, -- Jesse Guardiani, Systems Administrator WingNET Internet Services, P.O. Box 2605 // Cleveland, TN 37320-2605 423-559-LINK (v) 423-559-5145 (f) http://www.wingnet.net