Thread: memory question

  1. #1
    EOF
    Join Date
    Aug 2005
    Location
    Constanta, RO, Europe
    Posts
    46

    memory question

    do dynamic allocation functions like malloc and so use the whole RAM and swap, or only 64k? the same about static allocation.

    i migrated from pascal so...
    Two strings walk into a bar. The first one says, 'Bartender! Bartender! I want a drink!'. The second one says, 'Bartender! Bartender! I want a drink too! Blaaaaaaaaah eeeeeeeek yaaaaaaak oooooooh'. The first one says, 'Please excuse my friend. He isn't null term--'.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    There isn't a limitation in the language itself on how big a chunk of memory you can allocate, other than what fits in the data type. Even that isn't the language saying "you can't allocate more", it's simply a limitation of the data type you pass as an argument to malloc or calloc.

    If you have an old compiler, you're going to hit the 64K segment limitation, again due to the data type's size.

    What you ask is really an OS / compiler specific question. The language doesn't limit you, other than what I've mentioned above. Since it doesn't, you've next got to look at the OS / hardware etc you're running on. If you only have RAM, and no swap, you're going to be limited by that. Otherwise, it'll potentially use both.

    There are going to be some data segment size limitations you'll run into. These also are mainly due to the size of the data type itself. Dynamic allocation isn't going to have the same problem of running out of stack space and what not that you declaring an array would have.

    I'm not an expert on the subject, so perhaps someone else will put it better than I have.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    64K?
    What stone-age compiler are you using?

    Get a 32 bit compiler, then your malloc will be able to access whatever the OS cares to give you by way of virtual memory.
    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.

  4. #4
    EOF
    Join Date
    Aug 2005
    Location
    Constanta, RO, Europe
    Posts
    46
    i'll happily get a new compiler but:
    1. don't know a thing in win32 programming
    2. i gennerally try to make dos/win16/unix/linux compliant progs.
    3. borlandc is the only i have. all the results of google either are not free, either suck, either it's devcpp which doesn't work on my comp -- wonder why -- but the thing that mostly annoyes me is that i can't run a graphical linux (mouse not detected). i tried a gcc compile, but it had no header files, and just didn't know how to get them (what is the name of the package containing them)
    Two strings walk into a bar. The first one says, 'Bartender! Bartender! I want a drink!'. The second one says, 'Bartender! Bartender! I want a drink too! Blaaaaaaaaah eeeeeeeek yaaaaaaak oooooooh'. The first one says, 'Please excuse my friend. He isn't null term--'.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    1) You don't need to compile WinAPI programs to build programs which compile under Windows, if that's what you're using.
    2) Sounds like you should get gcc then.
    3) Search for cygwin. (Or just go to Cygwin.com...)


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > 1. don't know a thing in win32 programming
    32 bit != win32
    You can create 32 bit console programs without any difficulty.

    http://www.thefreecountry.com/compilers/cpp.shtml
    http://www.compilers.net/

    > doesn't work on my comp -- wonder why
    No idea - did you ever post a message asking why?
    Did you ever consult the homepage FAQ?


    > i tried a gcc compile, but it had no header files
    Well locate the glibc (GNU 'C' library) which goes with it. The compiler is just that - a compiler. You need a bunch of header files and libraries to go with it.
    Most Linux distro's should have that as part of the CD bundle.
    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.

  7. #7
    EOF
    Join Date
    Aug 2005
    Location
    Constanta, RO, Europe
    Posts
    46
    so, win32 means winapi and 32bit just means 32bit platform? interesting...

    oh, i got a netinst debian so no wonder there was no library... stupid me
    Two strings walk into a bar. The first one says, 'Bartender! Bartender! I want a drink!'. The second one says, 'Bartender! Bartender! I want a drink too! Blaaaaaaaaah eeeeeeeek yaaaaaaak oooooooh'. The first one says, 'Please excuse my friend. He isn't null term--'.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. heap vs stack memory question
    By donglee in forum C++ Programming
    Replies: 4
    Last Post: 01-23-2009, 04:34 PM
  2. Pointer memory question
    By Edo in forum C++ Programming
    Replies: 5
    Last Post: 01-21-2009, 03:36 AM
  3. Memory question
    By John_L in forum Tech Board
    Replies: 8
    Last Post: 06-02-2008, 10:06 PM
  4. Another Dynamic Memory Question
    By SirCrono6 in forum C++ Programming
    Replies: 6
    Last Post: 03-02-2005, 12:10 PM
  5. Is it necessary to write a specific memory manager ?
    By Morglum in forum Game Programming
    Replies: 18
    Last Post: 07-01-2002, 01:41 PM