Mem alloc

This is a discussion on Mem alloc within the C Programming forums, part of the General Programming Boards category; Hello. A quick (stupid) question... I used to do a lot of C on DOS/MS C/Borland compilers. As I understand ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    9

    Mem alloc

    Hello.

    A quick (stupid) question...

    I used to do a lot of C on DOS/MS C/Borland compilers.
    As I understand the malloc() function used to allocated memory from "DOS" or "BASE" memory, which was 640K(w/o Himem) if you wanted to use anymore, you'd need protected mode, EMM, etc and was quite difficult - so I used to use files instead (because I'm a lazy quitter :-))

    Under linux/gcc, what memory am I getting when I use malloc()? I thought it was all the RAM availible, but just saw it run out of mem when allocating mem for 60,000 data structures and the RS/6000 I'm doing it on has 16GB RAM...

    I was also under the impression that the BIOS has something to do with the 640k base but RS6k - no BIOS...

    would anyone be kind enough to put straight my meed up brain on this matter?

    Thanks

    Daz.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    > Under linux/gcc, what memory am I getting when I use malloc()?
    Virtual memory, which has nothing (or not much) to do with how much physical memory you have.

    > run out of mem when allocating mem for 60,000 data structures
    But how big was each structure instance?

    Linux (like all protected operating systems) has the ability to restrict the amount of memory any single process can allocate. Use the "ulimit" command to find out what the limits are for you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    9
    Hi,

    Thanks for your prompt reply.

    ulimit replies "unlimited"

    Don't know at the moment how big one of my data structures is but 60,000 is a silly amount - 800 will be more than enough but I was trying to see where my limits are. Will be doing this project on a Intel which is replacement for the afore mentioned RS but the PC and RS both give me my highly descriptive "not aloc mem" error message :-) at the same place, just made me think back to the days of DOS and its rubbish base memory system.

    Thanks for your help.
    Daz.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Structs and mem allocation
    By reversaflex in forum C Programming
    Replies: 2
    Last Post: 07-03-2008, 07:46 AM
  2. Replies: 6
    Last Post: 06-02-2006, 08:32 AM
  3. dynamic mem allocation prgm crash
    By rip1968 in forum C++ Programming
    Replies: 11
    Last Post: 05-10-2002, 05:09 PM
  4. dynamic mem alloc of 2-d arrays
    By hankspears in forum C Programming
    Replies: 6
    Last Post: 04-09-2002, 02:30 PM

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