Thread: malloc failure - is there some way to allocate a bigger heap/whatever?

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    161

    malloc failure - is there some way to allocate a bigger heap/whatever?

    I'm trying to allocate memory for a huge global array of structs, but it's apparently hitting some internal limit. Compiler (Dev-C/MinGW) wouldn't compile it with a default size set, and malloc after program load fails. What do I do to get access to more memory? I have 2 gigs of RAM, mostly free, so it shouldn't be an issue of physical memory.

    edit: I'm trying to cut down on the amount of memory I'll need. I'd still like to know some specifics about these limitations.
    Last edited by Viper187; 10-19-2008 at 01:44 PM.

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    How much are you trying to get?

    If you have 2GB of memory, and you have an operating system running, plus an editor or IDE, you don't have 2GB available.
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    161
    Quote Originally Posted by Dino View Post
    How much are you trying to get?

    If you have 2GB of memory, and you have an operating system running, plus an editor or IDE, you don't have 2GB available.
    That's obvious.

    I guess I was trying to get more than I thought though. I've got it down to 40 meg or so and it's working.

  4. #4
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    If you are on UNIX then you are hitting either the max stack size or max data size limit depending on whether the large array of structs is defined within a function or not.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. malloc error can't allocate region on mac os X
    By simone.marras in forum C Programming
    Replies: 6
    Last Post: 02-28-2009, 05:59 AM
  2. Where does malloc() allocate to?
    By someprogr in forum C Programming
    Replies: 9
    Last Post: 09-06-2008, 06:10 PM
  3. Replies: 28
    Last Post: 12-10-2004, 06:49 AM
  4. conditions of failure... malloc that is...
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 12-08-2001, 06:47 PM
  5. How do I use malloc to allocate memory for a linked list?
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-14-2001, 01:02 PM