Re: Memory allocation troubles
- From: John Vetterli <jvetterli linux ca>
- To: gtk-app-devel-list gnome org
- Subject: Re: Memory allocation troubles
- Date: Tue, 19 Oct 2004 11:09:08 -0400
On Tue, 19 Oct 2004 09:27:22 +0200
Olaf Fr±czyk <olaf cbk poznan pl> wrote:
I write an application that requires much memory to run.
It is impossible to assume that every time I ask for memory I'll get
it. Aborting program is not an option, because before dying I need to
clean things up.
If you're running this program on Linux, you have a bit of a problem.
When a process asks the Linux kernel for more memory, the kernel
increases size of the process' data segment, but does not actually
assign physical memory (ram or swap) until the program tries to access
it. So while the initial call to malloc (and therefore g_new) may
succeed, your program may still be suddenly terminated if the system
runs out of memory.
From the linux malloc(3) manpage:
"Linux follows an optimistic memory allocation strategy. This means
that when malloc() returns non-NULL there is no guarantee that the
memory really is available. In case it turns out that the system
is out of memory, one or more processes will be killed by the infamous
OOM killer."
JV
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]