Date: Thu, 12 Aug 1999 10:09:13 -0600 From: Charles Randall <crandall@matchlogic.com> To: Alec Kalinin <alec@relex.ru> Cc: freebsd-questions@freebsd.org Subject: RE: Problem with allocation memory in FreeBSD-3.2-RELEASE Message-ID: <64003B21ECCAD11185C500805F31EC0303786BD3@houston.matchlogic.com>
next in thread | raw e-mail | index | archive | help
Looks like you're simply running the system out of swap by allocating and
touching 1 MB one thousand times for a total of 1 GB.
Malloc will eventually return NULL to indicate the system is out of memory.
Since you don't check for this, I'd expect a core dump when malloc returns
NULL and then you try to fill with zeros.
What did you expect to happen?
Charles
-----Original Message-----
From: Alec Kalinin [mailto:alec@relex.ru]
Sent: Thursday, August 12, 1999 4:18 AM
To: freebsd-questions@freebsd.org
Subject: Problem with allocation memory in FreeBSD-3.2-RELEASE
Hello!
I have a problem with allocation memory in FreeBSD-3.2-RELEASE. This simple
program hungs my system:
------------------- begin program -----------------------------
#include <unistd.h>
#include <stdlib.h>
#define NALLOC 1000
#define SIZEALLOC 1024*1024
#define WAIT 100
void main()
{
char *p_mem;
int i, j;
if (fork() != 0) return;
for (i=0; i<NALLOC; i++) {
// usleep(WAIT);
p_mem = (char *)malloc(SIZEALLOC);
for (j=0; j<SIZEALLOC; j++) {
p_mem[j] = 0;
}
}
while (1);
}
------------------- begin program -----------------------------
I have a swap space about 100 M. After run this program, i can't write
something to my consoles -- system like hang system. But it answer for ping.
It may be my problem, but it may be kernel problem ;)
P.S. My English is not as well, as i want. If you have troubles with read my
letter, sorry.
Good luck,
Alec
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?64003B21ECCAD11185C500805F31EC0303786BD3>
