gabriel rosenkoetter on 24 Nov 2003 15:24:02 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Why am I running out of memory?


On Mon, Nov 24, 2003 at 01:14:39PM -0500, Walt Mankowski wrote:
> Well, I do and I don't.  I do have access to the Matrix library, but
> it's just a C++ class and it just allocates memory using new.  It
> never calls mmap directly.  I assume it's happening deep inside g++
> somewhere.

Well, if you've got that source, you could overload new for that
object and do what MCT suggested (mmap(2) a file rather than touch
memory at all, since you're going to end up bound by disk speed if
you're going to be hitting swap before you do anything useful
anyway). That's a pretty ugly solution, though.

On Mon, Nov 24, 2003 at 01:30:15PM -0500, Will Dyson wrote:
> Actually, the kernel will evict userspace _pages_ on a LRU basis. It
> doesn't care about the state of the processes owning the pages. Pages
> that are part of a shared library or multiply mmap()ed file have no
> definitive process that owns them.

Erm. Yes, true. I answered mostly without thinking. You *can* swap a
process (and all pages it contains), which is what I'd expect the
kernel should be doing (and appears to be trying to do based on
Toby's latest email).

On Mon, Nov 24, 2003 at 01:32:45PM -0500, Tobias DiPasquale wrote:
> Where did you hear that? That's not true, at all. It certainly can swap
> out pages from the currently-running process. Otherwise, a local user
> could DoS a Linux box very easily.

Yeah, I was simply wrong, by not actually thinking about the
question.

The point I may have been trying to make is that it's *possible* to
kick a process out to swap wholesale if it's not runnable, but that
that couldn't happen in this case.

Paging out anon pages owned by processes that are runnable and
running is what causes thrashing, of course.

On Mon, Nov 24, 2003 at 01:37:39PM -0500, Tobias DiPasquale wrote:
> the _process of swapping_ that's causing your process to die. During the
> very long and winding call chain that emerges from sys_mmap2() (the
> in-kernel function that's called when your program calls mmap2()), at
> some point it attempts to swap out some pages and calls out_of_memory()
> because try_to_free_pages_zone() fails to free enough pages to satisfy
> the request and, thus, your process is killed.

I *think* this makes sense to me, but I'm not sure it answers the
underlying question (which is "Why did try_to_free_pages_zone()
fail?).

-- 
gabriel rosenkoetter
gr@eclipsed.net

Attachment: pgpKsDIXinSkH.pgp
Description: PGP signature