Skip site navigation (1)Skip section navigation (2)
Date:      12 Oct 1998 21:39:28 +0200
From:      dag-erli@ifi.uio.no (Dag-Erling C. =?iso-8859-1?Q?Sm=F8rgrav?= )
To:        dg@root.com
Cc:        freebsd-bugs@FreeBSD.ORG
Subject:   Re: bin/8275: w/top/etc randomly fail with 'Cannot allocate memory'
Message-ID:  <xzp1zodsh73.fsf@hall.ifi.uio.no>
In-Reply-To: David Greenman's message of "Mon, 12 Oct 1998 12:31:08 -0700"
References:  <199810121931.MAA02205@implode.root.com>

next in thread | previous in thread | raw e-mail | index | archive | help
David Greenman <dg@root.com> writes:
>    It should pad "size" with a few processes worth (perhaps increase it by
> 10%...size += size / 10).

Yes.

Do I have your approval to commit the following patch:

Index: kvm_proc.c
===================================================================
RCS file: /home/ncvs/src/lib/libkvm/kvm_proc.c,v
retrieving revision 1.21
diff -u -r1.21 kvm_proc.c
--- kvm_proc.c  1998/09/16 04:17:46     1.21
+++ kvm_proc.c  1998/10/12 19:39:14
@@ -302,10 +302,16 @@
                        _kvm_syserr(kd, kd->program, "kvm_getprocs");
                        return (0);
                }
-               kd->procbase = (struct kinfo_proc *)_kvm_malloc(kd, size);
-               if (kd->procbase == 0)
-                       return (0);
-               st = sysctl(mib, op == KERN_PROC_ALL ? 3 : 4, kd->procbase, &size, NULL, 0);
+               kd->procbase = 0;
+               do {
+                       size += size / 10;
+                       kd->procbase = (struct kinfo_proc *)_kvm_realloc(kd,
+                                                                        size);
+                       if (kd->procbase == 0)
+                               return (0);
+                       st = sysctl(mib, op == KERN_PROC_ALL ? 3 : 4,
+                                   kd->procbase, &size, NULL, 0);
+               } while (st == -1 && errno == ENOMEM);
                if (st == -1) {
                        _kvm_syserr(kd, kd->program, "kvm_getprocs");
                        return (0);


DES
-- 
Dag-Erling Smørgrav - dag-erli@ifi.uio.no

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzp1zodsh73.fsf>