Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Oct 1998 12:31:08 -0700
From:      David Greenman <dg@root.com>
To:        dag-erli@ifi.uio.no (Dag-Erling C. =?iso-8859-1?Q?Sm=F8rgrav?= )
Cc:        freebsd-bugs@FreeBSD.ORG
Subject:   Re: bin/8275: w/top/etc randomly fail with 'Cannot allocate memory' 
Message-ID:  <199810121931.MAA02205@implode.root.com>
In-Reply-To: Your message of "Mon, 12 Oct 1998 11:40:01 PDT." <199810121840.LAA26956@freefall.freebsd.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
> If my reasoning is correct, the following (untested) patch should
> solve this:
> 
> 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 18:33:58
> @@ -302,10 +302,15 @@
>                         _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 {
> +                       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);

   It should pad "size" with a few processes worth (perhaps increase it by
10%...size += size / 10).

-DG

David Greenman
Co-founder/Principal Architect, The FreeBSD Project

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?199810121931.MAA02205>