Thread: C++ Explict Dynamic Memory Allocation - Why?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by grumpy View Post
    The distinction between heap and stack - and any performance benefits of using one or the other - has been minimal or non-existent with modern operating systems since the mid 1990s
    I don't see how they could possibly have eliminated the copying penalty at the operating system level. the only way I can think of is to use the x86 paging mechanism and copy-on-write, but that would give application code a lot of low level access to kernel-space things.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by Elkvis View Post
    I don't see how they could possibly have eliminated the copying penalty at the operating system level. the only way I can think of is to use the x86 paging mechanism and copy-on-write, but that would give application code a lot of low level access to kernel-space things.
    My comment that you quoted concerned different performance (or lack thereof in modern systems) offered by heap and stack, not on the overhead of copying objects.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by grumpy View Post
    My comment that you quoted concerned different performance (or lack thereof in modern systems) offered by heap and stack, not on the overhead of copying objects.
    any system that accesses memory as a contiguous block will have no penalty for heap versus stack access.

    While it is true that modern operating systems impose address quotas on processes, the quotas are usually much larger than 1MB.
    as an example, the default stack size for a win32 thread is 1MB, if you specify 0 for stack size when calling CreateThread(). since you cannot always be sure you are not running in a child thread (without explicitly checking for it), it's not unreasonable to expect that you might need to plan for this situation.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic Memory Allocation
    By JamesD in forum C Programming
    Replies: 10
    Last Post: 03-12-2011, 12:08 AM
  2. what is dynamic memory allocation
    By dbzx in forum C Programming
    Replies: 7
    Last Post: 06-08-2009, 08:11 AM
  3. Memory dynamic allocation
    By elvio.vicosa in forum C Programming
    Replies: 8
    Last Post: 10-16-2007, 03:30 AM
  4. Help with dynamic memory allocation
    By malooch in forum C Programming
    Replies: 2
    Last Post: 12-13-2006, 01:26 PM
  5. Dynamic Memory Allocation
    By oranges in forum C++ Programming
    Replies: 3
    Last Post: 11-28-2006, 07:50 AM