Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualCornstalks

Posted 24 December 2012 - 10:35 AM

Stack allocators exists, but they're non-standard and you shouldn't mess with a custom allocator unless you really know what you're doing. Sounds like you're trying to optimize in the wrong place.

 

Just allocate on the heap. Large objects on the stack should be avoided because the stack is usually pretty small (when compared to the heap) so it's easy to run out of space, especially if you ever do anything recursive.

 

Why do you have an aversion to allocating on the heap in this situation? The stack isn't magically faster than the heap. It's all just stored in your RAM. Putting too much on the stack, or in the wrong order, may mess with your cache hit/miss rate, too.


#1Cornstalks

Posted 24 December 2012 - 10:33 AM

Stack allocators exists, but they're non-standard and you shouldn't mess with a custom allocator unless you really know what you're doing. Sounds like you're trying to optimize in the wrong place.

 

Just allocate on the heap. Large objects on the stack should be avoided because the stack is usually pretty small (when compared to the heap) so it's easy to run out of space, especially if you ever do anything recursive.

 

Why do you have an aversion to allocating on the heap in this situation?


PARTNERS