SUMMARY: SunOS 4.1.3 memory problems??

From: Sven Ole Skrivervik (
Date: Wed Apr 21 1993 - 10:53:11 CDT

Thanks for all the answers on this one.

The information that I feel is critical to know here is that
vmstat is kind of lying on free memory here. All free memory
is used as file cache. These pages are still in the kernel cache list
and are not "freed" in the sence that vmstat would report the memory
as available after the copy is done. However if a process needs
them it'll get them and there should not be any paging/swapping
problems after such a copy. If this is so the reason is probably
because of sudden, large demands for memory.

I've done some tests with a program that allocates a certain amount
of memory and exits. Running this program after the copy will make
the memory pages free in the sence that vmstat will report the memory
as available.

Other solutions like using the gnu cp program, umounting the filesystem
and so on didn't quite solve my "problem", but thanks anyhow.

Thanks to:

- Sven Ole

The malloc program:

#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/lock.h>

#ifdef DGUX
#include <sys/mman.h>

extern char *malloc();
extern int plock();
extern unsigned sleep();
extern void perror();
extern int errno;
long size,i;
char *mem;
int status, seconds;

extern char *optarg; /* parameters for getopt */
extern int optind;
char **ppeker; /* parameters for strtol */
char *peker;
int base = 0;

long mbytes; /* Number of bytes to malloc */
long wbytes; /* Number of bytes to write */
long fbytes; /* Number of bytes to fix */

main (argc, argv)
int argc;
char **argv;

     int c;
     int errflg;
     char *marg = 0, *warg = 0, *farg = 0;
     int mflg = 0, wflg = 0, fflg = 0;
     long apar;
     errflg = 0;
     ppeker = &peker;
     if (argc < 2) errflg++;
     while ((c = getopt(argc, argv, "m:w:f:")) != -1)
          switch (c) {
          case 'm':
               printf(" m option : \n");
               marg = optarg;
          case 'w':
               printf(" w option : \n");
               mflg++; wflg++;
               marg = optarg;
          case 'f':
               printf(" f option : \n");
               mflg++; wflg++; fflg++;
               marg = optarg;
          case '?':
     if (errflg) {
        (void)fprintf(stderr,"usage: malloc -<option> <size> \n");
        (void)fprintf(stderr," <option> m: malloc only \n");
        (void)fprintf(stderr," <option> w: malloc and write \n");
        (void)fprintf(stderr," <option> f: malloc, write and fix. \n");
        exit (2);
     if (mflg) {
          apar = strtol(marg, ppeker, base);
          mbytes = apar;
          printf(" Memory buffer.");
          c = **ppeker;
          switch (c) {
          case 'k': case 'K':
               mbytes = apar * 1024;
               printf(" %ld Kbytes. ",apar);
          case 'm': case 'M':
               mbytes = apar * 1024 *1024;
               printf(" %ld Mbytes. ",apar);
          printf(" Total %ld bytes \n",mbytes);
     wbytes = mbytes;
     fbytes = mbytes;
     if (mflg) {
          printf (" Start malloc.\n");
          mem = malloc(mbytes);
          if (mem == NULL) {
               printf("\nMalloc failed, errno : %d\n",errno);
     if (wflg) {
          printf (" Start writing.\n");
          for (i=0;i<wbytes-512;i+=512) {
               mem[i] = i;
     if (fflg) {
          printf (" Start locking.");

#ifdef DGUX
          status = mlockall(MCL_CURRENT|MCL_FUTURE);
          printf (" (mlock) \n");
          status = plock(DATLOCK);
          printf (" (plock) \n");
          if (status != 0) {
            printf("\nPlock failed, status: %d, errno: %d\n",status,errno);
            exit (status);
     printf ("\n Ready.\n ");
/* seconds = 1000000;
     printf("\nStop the program by using <Ctrl C> or <kill> command\n");

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:07:45 CDT