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

This is a discussion on malloc failure - is there some way to allocate a bigger heap/whatever? within the C Programming forums, part of the General Programming Boards category; I'm trying to allocate memory for a huge global array of structs, but it's apparently hitting some internal limit. Compiler ...

  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
    Katy, Texas
    Posts
    2,309
    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.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  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,047
    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, 04: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, 05: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, 05: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21