git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: fatal: Out of memory, malloc failed

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Apr 13, 2007, 18:53 UTC
Message-ID
<Pine.LNX.4.64.0704131143130.28042@woody.linux-foundation.org>
In-Reply-To
<461FBD02.6050105@eircom.net>
On Fri, 13 Apr 2007, Alan Larkin wrote:
> 
> Its not a huge push Im trying to do here (<about 150Mb) but always malloc fails!
Any huge objects?

Also, it might be interesting to run it under gdb, and put a breakpoint on the "die" function, so that it stops where it runs out of memory. Then. at that point, you can:

 - do a "where" in gdb to see what allocation it is (and ask it how big 
   it was by printing out the value of "size").
   It may be something totally uninteresting (just some random object that 
   happened to push things over the limit), but statistically, malloc 
   failures tend to happen to big objects, and sometimes just because 
   somebody needed a huge area that won't fit in the virtual address 
   space.
 - check with "ps" what the size of the process is. Maybe you even just 
   have some process limit set that causes brk/mmap to return failure 
   earlier than necessary..
   (It can also be interesting to look at /proc/<pid>/maps, in case
   there are big mmaps that fill up the VM etc)

Sometimes it's also a good idea to have a swap file. You may not even *need* to actually page, but it gives thew VM layer much more freedom, especially if your distro has set the flags to disable memory "overcommit".

		Linus
Previous: Alan LarkinNext: Alan Larkin
Message 2 of 11 in “fatal: Out of memory, malloc failed”
  1. Alan LarkinApr 13, 2007
  2. Linus TorvaldsApr 13, 2007
  3. Alan LarkinApr 15, 2007
  4. Alex RiesenApr 15, 2007
  5. Alan LarkinApr 16, 2007
  6. Julian PhillipsApr 16, 2007
  7. Alan LarkinApr 16, 2007
  8. Alex RiesenApr 16, 2007
  9. Alex RiesenApr 16, 2007
  10. Alan LarkinApr 16, 2007
  11. Alex RiesenApr 16, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.