Tuesday, September 28, 2010

Stack Usage



Do not damage the stack!

Use BREW 鈩? running each program has a call stack and heap, and each room has a maximum limit. If you exceed the maximum stack space in the absence of their situation can not be extended, and another memory allocation attempt fails, the application should detect this situation and try to moderate handling. However, if the stack extend beyond the maximum amount of space (known as the "destruction of the stack"), the data will be overwritten. This can lead to seemingly random but often very strange phenomenon of defect or breakdown. Destruction of the stack is kind of hard to debug, because it may be related with the data, does not occur in the simulator and the code looks like no problem.

Be sure to keep your stack size of 500 bytes of the following.

To reduce the stack size, try to keep calls short depth (to avoid recursive function calls or embedded deep). Moreover, in addition to simple items (such as int, pointer, and other scalar types), were invited to consider the dynamic allocation of memory, rather than declare a variable on the stack. For example, to avoid the buffer within the function declaration, declare a pointer and dynamically allocate the buffer. To further reduce memory usage and object code size, preferably in multiple function use global buffers, rather than the local buffer.

Reduce the call depth approach is to manually unlock your code (from the other cases, the function will be called to extract the code and insert it in other circumstances would call its functions).

Another method is to use the INLINE function declaration specification. However, please note that the compiler may not perform INLINE command. For example, the time of writing this report that some people ignore the ARM C compiler INLINE. Can use ARM C + + compiler (even if you write the conventional C code). In addition, many compilers do not inline calls from outside the function declaration file function.








相关链接:



The world to those who have Access



Business Components 2



Knowledge of equality before the



YouTube to WMV



QuickTime to MPG



The second Mix CorelDRAW9



WMV to Zune



Tencent sued Staff: to protest the labor CONTRACT Tencent Overlord



FreeBSD SERIAL (35): serial port and modem



Overcome stage fright interview the 10 candidates RECRUITED nirvana



Picked Personal Finance



Firewall And Proxy Servers COMMENTS



Using warm and intimate SMALL music prompted the fish that you're familiar with the music fish



No comments:

Post a Comment