[U-Boot] [U-BOOT] [PATCH] env: reduce the stack footprint for the env buf

Wolfgang Denk wd at denx.de
Fri Feb 4 22:18:37 CET 2011


Dear Lei Wen,

In message <1296788903-7604-1-git-send-email-leiwen at marvell.com> you wrote:
> Original env buf directly locate at stack lead large stack footprint
> when call those env functions. It is not good when the system memory
> is critical or only want the uboot run at restrict range, that is not
> to touch the memory of other place at its best.
> 
> So now this patch move the env buf to the heap area, which reduce the
> area uboot need to touch.

In which way do you think this will save any memory?

Your switch from automatic variables to manually allocated ones has,
in my opinion several disadvantages:

1) It increases the code size.

2) It increases the probability of bugs like memory leaks etc.

3) Instead of using the stack, which gets allocated fully dynamically
   and gets freed guaranteed completely when the function returns,
   you now need at least the same space in the malloc arena - where
   you have to allocate it statically, and where allocations of
   buffers like that can easily lead to memory fragmentation,
   increasing the memory footprint further.

Did you do any specific measurements of memory footprint, or what
makes you believe your code is preferrable?


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
As far as the laws of mathematics refer to reality, they are not cer-
tain, and as far as they are certain, they do not refer  to  reality.
                                                   -- Albert Einstein


More information about the U-Boot mailing list