Re: malloc does not return null when out of memory

From: Wes Peters (wes_at_softweyr.com)
Date: 07/28/03

  • Next message: Kevin Oberman: "Re: DVD Drive wont mount"
    To: Barney Wolff <barney@databus.com>, Doug White <dwhite@gumbysoft.com>
    Date: Mon, 28 Jul 2003 13:45:58 -0700
    
    

    On Wednesday 23 July 2003 15:13, Barney Wolff wrote:
    > On Wed, Jul 23, 2003 at 02:09:00PM -0700, Doug White wrote:
    > > On Wed, 23 Jul 2003, Gabor wrote:
    > > > We have a little soekris box running freebsd that uses racoon for
    > > > key management. It's used for setting up an ipsec tunnel. I
    > > > noticed that one of these devices lost the tunnel this morning.
    > > > I looked in the log and saw this
    > > >
    > > > Jul 23 01:37:57 m0n0wall /kernel: pid 80 (racoon), uid 0, was
    > > > killed: out of swap space
    > >
    > > [...]
    > >
    > > > Here is the tail end of the output. It dies when trying to poke
    > > > at the memory using memset. If I just malloc without the memset,
    > > > it never even dies.
    > >
    > > That's normal. If you malloc() memory and never touch it then it is
    > > never actually allocated.
    > >
    > > Your problem is that you're running out of memory. Try killing off
    > > unneeded daemons and set maxusers to a low value (like 32). Also
    > > try reducing the size of your mfs partitions, if you're using
    > > rc.diskless2. I don't think raccoon is much of a memory pig, unless
    > > you have a huge number of connections.
    >
    > Shouldn't malloc return 0 when out of memory rather than returning
    > an address that won't work? I believe that was the complaint.
    > Presumably having NO_SWAPPING has something to do with it, but
    > filling the swap might well do the same thing.

    Define "out of memory". FreeBSD employs swap overcommit; the memory
    pages aren't allocated until they are actually touched. This is such a
    Frequently Asked Question it's really a Constantly Asked Question and
    *any* search of the archives would've turned up dozens of conversations
    on this exact same topic.

    In other words, let's not carry this on any further.

    -- 
             "Where am I, and what am I doing in this handbasket?"
    Wes Peters                                              wes@softweyr.com
    _______________________________________________
    freebsd-stable@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-stable
    To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org"
    

  • Next message: Kevin Oberman: "Re: DVD Drive wont mount"

    Relevant Pages

    • Thank You -- Thomas J. Gritzan
      ... Thomas -- Your suggestion to malloc() out a block of memory was the ... Below are some details of my memory issues ... ... As a work around solution I guessed a ram disk would solve the ... persistence will frustrate the off topic police and give them a target ...
      (comp.lang.c)
    • Re: Simple question about headers and malloc!
      ... Therefore I am making all of its declarations ... memory (using malloc) and then exit back to main. ... allocation, I get data strored from the second allocation... ...
      (microsoft.public.vc.language)
    • Re: ten thousand small processes
      ... Stack needs to be executable for the current signal trampoline ... the use of malloc() that is causing your primary ... if there is any heap memory in use at all, no matter what you do, ... either directly, as a 4M page mapping (not used for user processes, ...
      (freebsd-performance)
    • Re: Review: My C FAQ Page
      ... the definition of memory leak is good but the information on ... this is not the most efficient way to allocate the 2-d array. ... You have ROW+1 calls to malloc. ... Allocate ROW pointers. ...
      (comp.lang.c)
    • Re: Help with Enter and Leave Instructions
      ... >>> for Memory Accesses, ... > The only standard way to do it is via malloc. ... Uh, SBRK/BRK is a standard, documented system call. ... > I really don't understand the objection to using C libraries. ...
      (alt.lang.asm)