Jivin Jan Ringoš lays it down ... > Hi everyone, > > I was investigating why some of my processes use too much memory than > expected (just by looking at /proc/pid/status), and found interesting > relation to stack size (set with elf2flt). I prefer to use stack wherever > possible instead of dynamic allocations for speed and to decrease > potential for memory leaks, but the numbers below somewhat confused me.
On a !MMU system, using the stack is not such a good idea IMO. The stack is fixed and must be allocated. Having a large stack just to cope with a config file parse or some other temporary use is just wasteful and forces you applications runtime memory usage to be higher than needed. > If I leave the stack at 4 kB, the memory usage is 40 kB for this > particluar program. > If I increase it to 32 kB, the memory usage jumps up to 250 kB or so. > I also tried to use 128 kB high stack, then the memory use happened to be > over 500 kB. > > In /proc/pid/maps I see that the most of this memory is single large > mapped block. > How can 28 kB of stack increase result in 200 kB of memory more being used? > Or am I completely missing something else? Sounds like you are using a power-of-2 allocator in your kernel. Take all your sizes, add them together then round up to the next power-of-2 to get the minimum size you will allocate. Though that doesn't quite add up in this case though, but it will get you a lot closer. Cheers, Davidm -- David McCullough, david_mccullo...@securecomputing.com, Ph:+61 734352815 McAfee - SnapGear http://www.snapgear.com http://www.uCdot.org _______________________________________________ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev