[lug] Huge stack size--any reason to avoid?

Sean Reifschneider jafo at tummy.com
Thu Oct 26 04:27:51 MDT 2006


On Wed, Oct 25, 2006 at 02:18:28PM -0600, Zan Lynx wrote:
>I suspect that the stack isn't fragmented at all.  A stack can't be,
>really.  The big memory use is probably allocated somewhere high up the

My understanding of the discussion about fragmented stack is what I'd call
duplicated objects on the stack.  If you're passing around a 1MB struct on
the stack, instead of the pointer to the object, and you have a 1MB L2
cache, you're going to end up having to hit main memory much more
frequently.  Because every function call with this big object is going to
create a new copy of this 1MB of data, and access the new copy.  When you
return, it's going to have to pull in the old copy from main memory.

L2 cache is something around 10x faster than main memory.

For this reason, it's much better to push around a small pointer to the
large chunk of memory, than to copy the data around.

It sounds to me like someone is saying "memory management is hard, let's go
shopping", and trying to be clever to work around it.  Few things can get
you in as much trouble as trying to be clever.  :-)

Sean
-- 
 There are things that are so serious that you can only joke about them.
                 -- Heisenberg
Sean Reifschneider, Member of Technical Staff <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995: Ask me about High Availability




More information about the LUG mailing list